Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » How to handle "null primary key encountered" exception?
How to handle "null primary key encountered" exception? [message #531645] Wed, 05 May 2010 16:41 Go to next message
Denys  is currently offline Denys Friend
Messages: 8
Registered: May 2010
Junior Member
Hi. I'm catching
... Null primary key encountered in unit of work clone ...

exception in eclipselink(2.0.2 with 2.0 jpa) literally meaning that id in my entity is <=0 (for primitive types). Though debug here states that everything's fine and I have nothing to worry about. My AS is glassfish v3. Can any one point out what may cause such behavior?

You may also find original description here.

Thanks in advance.
Re: How to handle "null primary key encountered" exception? [message #531985 is a reply to message #531645] Thu, 06 May 2010 17:07 Go to previous messageGo to next message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

As you stated, it means one of your objects has a null id, or <= 0. Ensure you are assigning an id to any new objects, or use a generated id.

Otherwise, please include the full stack trace to the exception and some details as to what you are doing to get the error. Also ensure you are not passing any references to detached objects that may have a null id.


James : Wiki : Book : Blog : Twitter
Re: How to handle "null primary key encountered" exception? [message #532141 is a reply to message #531985] Fri, 07 May 2010 10:26 Go to previous messageGo to next message
Denys  is currently offline Denys Friend
Messages: 8
Registered: May 2010
Junior Member
What I do is next:
1. Load entities (up to 50)
2. Try to delete one entity

It says that foreign key entity has a null primary key.
Here's the stack trace:


[#|2010-05-07T13:10:17.581+0300|INFO|glassfishv3.0|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=25;_ThreadName=http-thread-pool-8080-(1);|[EL Warning]: 2010-05-07 13:10:17.579--UnitOfWork(1337948674)--Exception [EclipseLink-7197] (Eclipse Persistence Services - 2.0.0.v20091127-r5931): org.eclipse.persistence.exceptions.ValidationException
Exception Description: Null primary key encountered in unit of work clone [my.package.persistence.entities.RegionsEntity@7439ef1b].
|#]

[#|2010-05-07T13:10:17.603+0300|SEVERE|glassfishv3.0|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=25;_ThreadName=http-thread-pool-8080-(1);|com.vaadin.event.ListenerMethod$MethodException
Cause: javax.persistence.RollbackException: Exception [EclipseLink-7197] (Eclipse Persistence Services - 2.0.0.v20091127-r5931): org.eclipse.persistence.exceptions.ValidationException
Exception Description: Null primary key encountered in unit of work clone [my.package.persistence.entities.RegionsEntity@7439ef1b].
	at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:507)
	at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:161)
	at com.vaadin.ui.AbstractComponent.fireEvent(AbstractComponent.java:1146)
	at com.vaadin.ui.Button.fireClick(Button.java:366)
	at com.vaadin.ui.Button.changeVariables(Button.java:188)
	at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.handleVariables(AbstractCommunicationManager.java:1087)
	at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.doHandleUidlRequest(AbstractCommunicationManager.java:587)
	at com.vaadin.terminal.gwt.server.CommunicationManager.handleUidlRequest(CommunicationManager.java:265)
	at com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:484)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
	at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
	at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
	at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
	at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:332)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:233)
	at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165)
	at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
	at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
	at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
	at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
	at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
	at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
	at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
	at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
	at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
	at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
	at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
	at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
	at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
	at java.lang.Thread.run(Thread.java:619)
Caused by: javax.persistence.RollbackException: Exception [EclipseLink-7197] (Eclipse Persistence Services - 2.0.0.v20091127-r5931): org.eclipse.persistence.exceptions.ValidationException
Exception Description: Null primary key encountered in unit of work clone [my.package.persistence.entities.RegionsEntity@7439ef1b].
	at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commitInternal(EntityTransactionImpl.java:102)
	at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commit(EntityTransactionImpl.java:63)
	at my.package.persistence.services.PersistenceService.removeEntity(PersistenceService.java:125)
	at my.package.infoform.modals.ConfirmationWindow$1.buttonClick(ConfirmationWindow.java:116)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:487)
	... 33 more
Caused by: Exception [EclipseLink-7197] (Eclipse Persistence Services - 2.0.0.v20091127-r5931): org.eclipse.persistence.exceptions.ValidationException
Exception Description: Null primary key encountered in unit of work clone [my.package.persistence.entities.RegionsEntity@7439ef1b].
	at org.eclipse.persistence.exceptions.ValidationException.nullPrimaryKeyInUnitOfWorkClone(ValidationException.java:1403)
	at org.eclipse.persistence.descriptors.changetracking.DeferredChangeDetectionPolicy.calculateChanges(DeferredChangeDetectionPolicy.java:106)
	at org.eclipse.persistence.descriptors.changetracking.DeferredChangeDetectionPolicy.calculateChangesForExistingObject(DeferredChangeDetectionPolicy.java:54)
	at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.calculateChanges(UnitOfWorkImpl.java:624)
	at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitToDatabaseWithChangeSet(UnitOfWorkImpl.java:1495)
	at org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork.commitRootUnitOfWork(RepeatableWriteUnitOfWork.java:200)
	at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitAndResume(UnitOfWorkImpl.java:1131)
	at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commitInternal(EntityTransactionImpl.java:84)
	... 41 more
|#]



Here is the my.package.persistence.services.PersistenceService.removeEnt ity() code:
			em.getTransaction().begin();
			try{
				em.remove(ent);
			} catch (Exception e) {
				// TODO: handle exception
			}  finally {
//125				em.getTransaction().commit();
			}

[Updated on: Fri, 07 May 2010 22:19]

Report message to a moderator

Re: How to handle "null primary key encountered" exception? [message #532277 is a reply to message #532141] Fri, 07 May 2010 18:44 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
What does the EsetRegionsEntity class look like (can you post its mappings), and is EsetRegionsEntity@7439ef1b the instance that remove was called on? Are there any events registered for the removed entity or processes that might change or affect primary keys?

Best Regards,
Chris
Re: How to handle "null primary key encountered" exception? [message #532828 is a reply to message #532277] Tue, 11 May 2010 10:40 Go to previous messageGo to next message
Denys  is currently offline Denys Friend
Messages: 8
Registered: May 2010
Junior Member
I think this will be enough code.

@Table(name = "regions", catalog = "catalog_name")
@Entity
public class RegionsEntity {
    private Long id;

    @Column(name = "id", nullable = false, insertable = true, updatable = true, length = 20, precision = 0)
    @Id
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    private String nameRu;

    @Column(name = "name_ru", nullable = false, insertable = true, updatable = true, length = 256, precision = 0)
    @Basic
    public String getNameRu() {
        return nameRu;
    }

    public void setNameRu(String nameRu) {
        this.nameRu = nameRu;
    }

    private String nameUk;

    @Column(name = "name_uk", nullable = false, insertable = true, updatable = true, length = 256, precision = 0)
    @Basic
    public String getNameUk() {
        return nameUk;
    }

    public void setNameUk(String nameUk) {
        this.nameUk = nameUk;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        RegionsEntity that = (RegionsEntity) o;

        if (id != that.id) return false;
        if (nameRu != null ? !nameRu.equals(that.nameRu) : that.nameRu != null) return false;
        if (nameUk != null ? !nameUk.equals(that.nameUk) : that.nameUk != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = (int) (id ^ (id >>> 32));
        result = 31 * result + (nameRu != null ? nameRu.hashCode() : 0);
        result = 31 * result + (nameUk != null ? nameUk.hashCode() : 0);
        return result;
    }

...

    private Collection<RegPurchaserEntity> regPurchasersById;

    @OneToMany(mappedBy = "regionsByRegionid")
    public Collection<RegPurchaserEntity> getRegPurchasersById() {
        return regPurchasersById;
    }

    public void setRegPurchasersById(Collection<RegPurchaserEntity> regPurchasersById) {
        this.regPurchasersById = regPurchasersById;
    }

    private Collection<RegPurchaserTempEntity> regPurchaserTempsById;

    @OneToMany(mappedBy = "regionsByRegionid")
    public Collection<RegPurchaserTempEntity> getRegPurchaserTempsById() {
        return regPurchaserTempsById;
    }

    public void setRegPurchaserTempsById(Collection<RegPurchaserTempEntity> regPurchaserTempsById) {
        this.regPurchaserTempsById = regPurchaserTempsById;
    }
}

No, I'm trying to delete another entity - RegPurchaserTempEntity - that is mapped to this entity.
Are there any events registered for the removed entity or processes that might change or affect primary keys? - well, I'm not 100% sure about that, but most likely the answer is no
Re: How to handle "null primary key encountered" exception? [message #533221 is a reply to message #531645] Wed, 12 May 2010 15:22 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
Hello,

I am not sure why it would discover the key to be changed/not there if it hasn't changed, and I'm not sure it is related to the remove. Can you post the RegPurchaserTempEntity's regionsByRegionid mapping, and show/describe how you are loading these entities? You might also try adding debug code to your entities to print off when the RegionsEntity setId is called (which will be quite a bit when EclipseLink populates objects) or possibly the RegionsEntity's toString method to show the entities Id and other values as well as the hashcode so that it shows up in the error.

Best Regards,
Chris
Re: How to handle "null primary key encountered" exception? [message #533227 is a reply to message #533221] Wed, 12 May 2010 15:52 Go to previous messageGo to next message
Denys  is currently offline Denys Friend
Messages: 8
Registered: May 2010
Junior Member
RegPurchaserTempEntity's code excerpt:

 private RegionsEntity regionsByRegionid;

    @ManyToOne
    public
    @JoinColumn(name = "regionid", referencedColumnName = "id", insertable = false, updatable = false)
    RegionsEntity getRegionsByRegionid() {
        return regionsByRegionid;
    }

    public void setRegionsByRegionid(RegionsEntity regionsByRegionid) {
        this.regionsByRegionid = regionsByRegionid;
    }


Mostly loading looks like this:
Query q = em.createNamedQuery("getRegBoxesByBoxProductName");
    	q.setParameter("name", name);
    	return new ArrayList<RegBoxesEntity>(q.getResultList());


As for the debug:

I used breakpoints and ran GFv3 in a debug mode to check ID's, so I don't think it will come in handy anyhow.
Re: How to handle "null primary key encountered" exception? [message #537518 is a reply to message #531645] Wed, 02 June 2010 18:03 Go to previous messageGo to next message
Gilberto Caetano de Andrade is currently offline Gilberto Caetano de AndradeFriend
Messages: 45
Registered: July 2009
Member
Hi,

I'm facing the same problem. I'm using orm.xml file. This one is my unit test.
And the exception:
-------------------------------------------------------------------------------
Test set: park.model.VehicleTest
-------------------------------------------------------------------------------
Tests run: 2, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 6.353 sec <<< FAILURE!
findAll(park.model.VehicleTest)  Time elapsed: 0.08 sec  <<< ERROR!
javax.persistence.RollbackException: Exception [EclipseLink-7197] (Eclipse Persistence Services - 2.0.2.v20100323-r6872): org.eclipse.persistence.exceptions.ValidationException
Exception Description: Null primary key encountered in unit of work clone [park.model.Customer[id=1000]].
        at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commitInternal(EntityTransactionImpl.java:102)
        at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commit(EntityTransactionImpl.java:63)
        at park.model.VehicleTest.findAll(VehicleTest.java:121)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
        at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
        at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
        at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
        at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
        at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:73)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:46)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
        at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
        at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
        at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
        at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
        at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
        at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
        at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345)
        at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009)
Caused by: Exception [EclipseLink-7197] (Eclipse Persistence Services - 2.0.2.v20100323-r6872): org.eclipse.persistence.exceptions.ValidationException
Exception Description: Null primary key encountered in unit of work clone [park.model.Customer[id=1000]].
        at org.eclipse.persistence.exceptions.ValidationException.nullPrimaryKeyInUnitOfWorkClone(ValidationException.java:1403)
        at org.eclipse.persistence.descriptors.changetracking.DeferredChangeDetectionPolicy.calculateChanges(DeferredChangeDetectionPolicy.java:106)
        at org.eclipse.persistence.descriptors.changetracking.DeferredChangeDetectionPolicy.calculateChangesForExistingObject(DeferredChangeDetectionPolicy.java:54)
        at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.calculateChanges(UnitOfWorkImpl.java:632)
        at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitToDatabaseWithChangeSet(UnitOfWorkImpl.java:1503)
        at org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork.commitRootUnitOfWork(RepeatableWriteUnitOfWork.java:200)
        at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitAndResume(UnitOfWorkImpl.java:1139)
        at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commitInternal(EntityTransactionImpl.java:84)
        ... 30 more


Can anyone help?

Thanks,

Gilberto
Re: How to handle "null primary key encountered" exception? [message #537728 is a reply to message #531645] Thu, 03 June 2010 13:33 Go to previous messageGo to next message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

That is odd, given the toString is printing an Id.

Is this your only test case, or do you have other test cases or classes that work? What is different about this test case, does it always fail?

Please include the mappings/annotations for the Customer.

The error is indicating that when EclipseLink tries to get the Id from the object, it gets null. Ensure that your get methods return the value, not null if using property access, and check that your Id has been mapped correctly.

You could try to debug the issue by putting a break point in the exception and checking why the object's Id is null in the debugger.


James : Wiki : Book : Blog : Twitter
Re: How to handle "null primary key encountered" exception? [message #537733 is a reply to message #537728] Thu, 03 June 2010 13:50 Go to previous messageGo to next message
Gilberto Caetano de Andrade is currently offline Gilberto Caetano de AndradeFriend
Messages: 45
Registered: July 2009
Member
Hi, James!

James wrote on Thu, 03 June 2010 09:33

Is this your only test case, or do you have other test cases or classes that work?


I have other tests that works. Just this one fail.

James wrote on Thu, 03 June 2010 09:33

What is different about this test case, does it always fail?


I can't see any difference. Yes it always fail!

James wrote on Thu, 03 June 2010 09:33

Please include the mappings/annotations for the Customer.


My post has the link for my orm.xml file and the test source code.

James wrote on Thu, 03 June 2010 09:33

You could try to debug the issue by putting a break point in the exception and checking why the object's Id is null in the debugger.


The exception occurs on commit method call.

Thanks for help,

Gilberto
Re: How to handle "null primary key encountered" exception? [message #538341 is a reply to message #531645] Mon, 07 June 2010 12:28 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 1
Registered: June 2010
Junior Member
do you have an id with value '0' in the db ?
Re: How to handle "null primary key encountered" exception? [message #538348 is a reply to message #538341] Mon, 07 June 2010 12:46 Go to previous messageGo to next message
Gilberto Caetano de Andrade is currently offline Gilberto Caetano de AndradeFriend
Messages: 45
Registered: July 2009
Member
No Real Name wrote on Mon, 07 June 2010 08:28
do you have an id with value '0' in the db ?


I didn't understand you question!
Did you look at the orm.xml and test source code file? Did you see that I'm testing Vehicle class and the exception is about Customer class?
Can you be more specific?

Thanks,


Gilberto
Re: How to handle "null primary key encountered" exception? [message #538407 is a reply to message #538348] Mon, 07 June 2010 15:10 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
Hello Gilberto,

Error is because EclpseLink is finding either null or an id value >=0 for the field it associates as Customer's pk. Customer's toString method prints off the id attribute, but EclpseLink will actually use the person relationship to control the primary key field due to it being marked with mapsId. Can you see the value of the mapping during debugging and verify if it is set (if using indirection, if the attribute is a valueholder and is triggered or not).

Best Regards,
Chris

Re: How to handle "null primary key encountered" exception? [message #538507 is a reply to message #538407] Mon, 07 June 2010 19:27 Go to previous messageGo to next message
Gilberto Caetano de Andrade is currently offline Gilberto Caetano de AndradeFriend
Messages: 45
Registered: July 2009
Member
Quote:
Can you see the value of the mapping during debugging and verify if it is set (if using indirection, if the attribute is a valueholder and is triggered or not).


No, it is not set! It means that in this call (see this image):
Customer c = em.find(Customer.class, 1000L);

it doesn't get everything necessary to satisfy the one-to-one relationship.

Since I'm using only orm.xml file, maybe I not configuring it the right way!
Any help/advice will be greatly appreciated,

Gilberto
Re: How to handle "null primary key encountered" exception? [message #538864 is a reply to message #538507] Tue, 08 June 2010 19:57 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
Odd, the relationship doesn't seem like it should have a problem, assuming that relationship is in the database. This is more common when not setting the relationship in the cached object - for instance if you persisted Customer and only set its Id attribute but not the person relationship and are attempting to read it later on.

Can you turn logging on Finest and post the logs? Also, after you do the find, can you print off the customer-> person relationship (just to verify that weaving didn't put indirection in the object which might explain the null in the debugger).

Best Regards,
chris
Re: How to handle "null primary key encountered" exception? [message #538876 is a reply to message #531645] Tue, 08 June 2010 20:53 Go to previous messageGo to next message
Gilberto Caetano de Andrade is currently offline Gilberto Caetano de AndradeFriend
Messages: 45
Registered: July 2009
Member
Hi,
That's the log:

NetBeans: Executing '/home/gilberto/bin/maven/bin/mvn -Dtest=VehicleTest -Dnetbeans.execution=true -Ph2,eclipselink test-compile surefire:test'
NetBeans:      JAVA_HOME=/usr/lib/jvm/java-1.5.0-sun
Scanning for projects...
Searching repository for plugin with prefix: 'surefire'.
------------------------------------------------------------------------
Building Parking Control - Core
   task-segment: [test-compile, surefire:test]
------------------------------------------------------------------------
[resources:resources]
Using 'UTF-8' encoding to copy filtered resources.
Copying 2 resources
[compiler:compile]
Compiling 13 source files to /home/gilberto/dev/netbeans-config/park-jpa/core/target/classes
[resources:testResources]
Using 'UTF-8' encoding to copy filtered resources.
Copying 15 resources
[compiler:testCompile]
Compiling 9 source files to /home/gilberto/dev/netbeans-config/park-jpa/core/target/test-classes
[surefire:test]
Surefire report directory: /home/gilberto/dev/netbeans-config/park-jpa/core/target/surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running park.model.VehicleTest
[EL Finest]: 2010-06-08 17:48:37.95--ServerSession(10519800)--Thread(Thread[main,5,main])--Begin predeploying Persistence Unit parkPU; session file:/home/gilberto/dev/netbeans-config/park-jpa/core/target/classes/_parkPU; state Initial; factoryCount 0
[EL Finest]: 2010-06-08 17:48:37.983--ServerSession(10519800)--Thread(Thread[main,5,main])--property=eclipselink.orm.throw.exceptions; default value=true
[EL Finer]: 2010-06-08 17:48:38.03--ServerSession(10519800)--Thread(Thread[main,5,main])--Searching for default mapping file in file:/home/gilberto/dev/netbeans-config/park-jpa/core/target/classes/
[EL Finer]: 2010-06-08 17:48:38.046--ServerSession(10519800)--Thread(Thread[main,5,main])--Found a default mapping file at file:/home/gilberto/dev/netbeans-config/park-jpa/core/target/classes/META-INF/orm.xml for root URL file:/home/gilberto/dev/netbeans-config/park-jpa/core/target/classes/
[EL Finer]: 2010-06-08 17:48:39.446--ServerSession(10519800)--Thread(Thread[main,5,main])--Searching for default mapping file in file:/home/gilberto/dev/netbeans-config/park-jpa/core/target/classes/
[EL Config]: 2010-06-08 17:48:39.549--ServerSession(10519800)--Thread(Thread[main,5,main])--The access type for the persistent class [class park.model.Parking] is set to [FIELD].
[EL Config]: 2010-06-08 17:48:39.579--ServerSession(10519800)--Thread(Thread[main,5,main])--The access type for the persistent class [class park.model.PriceTable] is set to [FIELD].
[EL Config]: 2010-06-08 17:48:39.581--ServerSession(10519800)--Thread(Thread[main,5,main])--The access type for the persistent class [class park.model.Stay] is set to [FIELD].
[EL Config]: 2010-06-08 17:48:39.583--ServerSession(10519800)--Thread(Thread[main,5,main])--The target entity (reference) class for the many to one mapping element [field employeeEntrance] is being defaulted to: class park.model.Employee.
[EL Config]: 2010-06-08 17:48:39.584--ServerSession(10519800)--Thread(Thread[main,5,main])--The target entity (reference) class for the many to one mapping element [field employeeOutgoing] is being defaulted to: class park.model.Employee.
[EL Config]: 2010-06-08 17:48:39.585--ServerSession(10519800)--Thread(Thread[main,5,main])--The target entity (reference) class for the many to one mapping element [field vehicle] is being defaulted to: class park.model.Vehicle.
[EL Config]: 2010-06-08 17:48:39.586--ServerSession(10519800)--Thread(Thread[main,5,main])--The target entity (reference) class for the many to one mapping element [field parking] is being defaulted to: class park.model.Parking.
[EL Config]: 2010-06-08 17:48:39.594--ServerSession(10519800)--Thread(Thread[main,5,main])--The access type for the persistent class [class park.model.Employee] is set to [FIELD].
[EL Config]: 2010-06-08 17:48:39.596--ServerSession(10519800)--Thread(Thread[main,5,main])--The target entity (reference) class for the many to one mapping element [field parking] is being defaulted to: class park.model.Parking.
[EL Config]: 2010-06-08 17:48:39.597--ServerSession(10519800)--Thread(Thread[main,5,main])--The access type for the persistent class [class park.model.Person] is set to [FIELD].
[EL Config]: 2010-06-08 17:48:39.598--ServerSession(10519800)--Thread(Thread[main,5,main])--The access type for the persistent class [class park.model.LegalEntity] is set to [FIELD].
[EL Config]: 2010-06-08 17:48:39.6--ServerSession(10519800)--Thread(Thread[main,5,main])--The access type for the persistent class [class park.model.VehicleType] is set to [FIELD].
[EL Config]: 2010-06-08 17:48:39.601--ServerSession(10519800)--Thread(Thread[main,5,main])--The access type for the persistent class [class park.model.Vehicle] is set to [FIELD].
[EL Config]: 2010-06-08 17:48:39.603--ServerSession(10519800)--Thread(Thread[main,5,main])--The target entity (reference) class for the many to one mapping element [field customer] is being defaulted to: class park.model.Customer.
[EL Config]: 2010-06-08 17:48:39.604--ServerSession(10519800)--Thread(Thread[main,5,main])--The target entity (reference) class for the many to one mapping element [field priceTable] is being defaulted to: class park.model.PriceTable.
[EL Config]: 2010-06-08 17:48:39.605--ServerSession(10519800)--Thread(Thread[main,5,main])--The target entity (reference) class for the many to one mapping element [field vType] is being defaulted to: class park.model.VehicleType.
[EL Config]: 2010-06-08 17:48:39.614--ServerSession(10519800)--Thread(Thread[main,5,main])--The access type for the persistent class [class park.model.NaturalPerson] is set to [FIELD].
[EL Config]: 2010-06-08 17:48:39.615--ServerSession(10519800)--Thread(Thread[main,5,main])--The access type for the persistent class [class park.model.Customer] is set to [FIELD].
[EL Config]: 2010-06-08 17:48:39.616--ServerSession(10519800)--Thread(Thread[main,5,main])--The alias name for the entity class [class park.model.Parking] is being defaulted to: Parking.
[EL Config]: 2010-06-08 17:48:39.618--ServerSession(10519800)--Thread(Thread[main,5,main])--The table schema for entity [file:/home/gilberto/dev/netbeans-config/park-jpa/core/target/classes/META-INF/orm.xml] is being defaulted to: park.
[EL Config]: 2010-06-08 17:48:39.648--ServerSession(10519800)--Thread(Thread[main,5,main])--The column name for element [field address] is being defaulted to: ADDRESS.
[EL Config]: 2010-06-08 17:48:39.651--ServerSession(10519800)--Thread(Thread[main,5,main])--The alias name for the entity class [class park.model.PriceTable] is being defaulted to: PriceTable.
[EL Config]: 2010-06-08 17:48:39.652--ServerSession(10519800)--Thread(Thread[main,5,main])--The table schema for entity [file:/home/gilberto/dev/netbeans-config/park-jpa/core/target/classes/META-INF/orm.xml] is being defaulted to: park.
[EL Config]: 2010-06-08 17:48:39.653--ServerSession(10519800)--Thread(Thread[main,5,main])--The alias name for the entity class [class park.model.Stay] is being defaulted to: Stay.
[EL Config]: 2010-06-08 17:48:39.654--ServerSession(10519800)--Thread(Thread[main,5,main])--The table schema for entity [file:/home/gilberto/dev/netbeans-config/park-jpa/core/target/classes/META-INF/orm.xml] is being defaulted to: park.
[EL Config]: 2010-06-08 17:48:39.666--ServerSession(10519800)--Thread(Thread[main,5,main])--The alias name for the entity class [class park.model.Employee] is being defaulted to: Employee.
[EL Config]: 2010-06-08 17:48:39.667--ServerSession(10519800)--Thread(Thread[main,5,main])--The table schema for entity [file:/home/gilberto/dev/netbeans-config/park-jpa/core/target/classes/META-INF/orm.xml] is being defaulted to: park.
[EL Config]: 2010-06-08 17:48:39.669--ServerSession(10519800)--Thread(Thread[main,5,main])--The alias name for the entity class [class park.model.LegalEntity] is being defaulted to: LegalEntity.
[EL Config]: 2010-06-08 17:48:39.675--ServerSession(10519800)--Thread(Thread[main,5,main])--The alias name for the entity class [class park.model.Person] is being defaulted to: Person.
[EL Config]: 2010-06-08 17:48:39.677--ServerSession(10519800)--Thread(Thread[main,5,main])--The table schema for entity [file:/home/gilberto/dev/netbeans-config/park-jpa/core/target/classes/META-INF/orm.xml] is being defaulted to: park.
[EL Config]: 2010-06-08 17:48:39.69--ServerSession(10519800)--Thread(Thread[main,5,main])--The column name for element [field address] is being defaulted to: ADDRESS.
[EL Config]: 2010-06-08 17:48:39.691--ServerSession(10519800)--Thread(Thread[main,5,main])--The column name for element [field name] is being defaulted to: NAME.
[EL Config]: 2010-06-08 17:48:39.692--ServerSession(10519800)--Thread(Thread[main,5,main])--The column name for element [field version] is being defaulted to: VERSION.
[EL Config]: 2010-06-08 17:48:39.697--ServerSession(10519800)--Thread(Thread[main,5,main])--The table schema for entity [file:/home/gilberto/dev/netbeans-config/park-jpa/core/target/classes/META-INF/orm.xml] is being defaulted to: park.
[EL Config]: 2010-06-08 17:48:39.699--ServerSession(10519800)--Thread(Thread[main,5,main])--The primary key column name for the inheritance class [class park.model.LegalEntity] is being defaulted to: id.
[EL Config]: 2010-06-08 17:48:39.7--ServerSession(10519800)--Thread(Thread[main,5,main])--The alias name for the entity class [class park.model.VehicleType] is being defaulted to: VehicleType.
[EL Config]: 2010-06-08 17:48:39.701--ServerSession(10519800)--Thread(Thread[main,5,main])--The table schema for entity [file:/home/gilberto/dev/netbeans-config/park-jpa/core/target/classes/META-INF/orm.xml] is being defaulted to: park.
[EL Config]: 2010-06-08 17:48:39.703--ServerSession(10519800)--Thread(Thread[main,5,main])--The alias name for the entity class [class park.model.Vehicle] is being defaulted to: Vehicle.
[EL Config]: 2010-06-08 17:48:39.705--ServerSession(10519800)--Thread(Thread[main,5,main])--The table schema for entity [file:/home/gilberto/dev/netbeans-config/park-jpa/core/target/classes/META-INF/orm.xml] is being defaulted to: park.
[EL Config]: 2010-06-08 17:48:39.706--ServerSession(10519800)--Thread(Thread[main,5,main])--The alias name for the entity class [class park.model.NaturalPerson] is being defaulted to: NaturalPerson.
[EL Config]: 2010-06-08 17:48:39.707--ServerSession(10519800)--Thread(Thread[main,5,main])--The table schema for entity [file:/home/gilberto/dev/netbeans-config/park-jpa/core/target/classes/META-INF/orm.xml] is being defaulted to: park.
[EL Config]: 2010-06-08 17:48:39.708--ServerSession(10519800)--Thread(Thread[main,5,main])--The primary key column name for the inheritance class [class park.model.NaturalPerson] is being defaulted to: id.
[EL Config]: 2010-06-08 17:48:39.71--ServerSession(10519800)--Thread(Thread[main,5,main])--The alias name for the entity class [class park.model.Customer] is being defaulted to: Customer.
[EL Config]: 2010-06-08 17:48:39.711--ServerSession(10519800)--Thread(Thread[main,5,main])--The table schema for entity [file:/home/gilberto/dev/netbeans-config/park-jpa/core/target/classes/META-INF/orm.xml] is being defaulted to: park.
[EL Finest]: 2010-06-08 17:48:39.791--ServerSession(10519800)--Thread(Thread[main,5,main])--End predeploying Persistence Unit parkPU; session file:/home/gilberto/dev/netbeans-config/park-jpa/core/target/classes/_parkPU; state Predeployed; factoryCount 0
[EL Finer]: 2010-06-08 17:48:39.793--Thread(Thread[main,5,main])--JavaSECMPInitializer - transformer is null.
[EL Finest]: 2010-06-08 17:48:39.793--ServerSession(10519800)--Thread(Thread[main,5,main])--Begin predeploying Persistence Unit parkPU; session file:/home/gilberto/dev/netbeans-config/park-jpa/core/target/classes/_parkPU; state Predeployed; factoryCount 0
[EL Finest]: 2010-06-08 17:48:39.794--ServerSession(10519800)--Thread(Thread[main,5,main])--End predeploying Persistence Unit parkPU; session file:/home/gilberto/dev/netbeans-config/park-jpa/core/target/classes/_parkPU; state Predeployed; factoryCount 1
[EL Finest]: 2010-06-08 17:48:39.804--ServerSession(10519800)--Thread(Thread[main,5,main])--Begin deploying Persistence Unit parkPU; session file:/home/gilberto/dev/netbeans-config/park-jpa/core/target/classes/_parkPU; state Predeployed; factoryCount 1
[EL Finer]: 2010-06-08 17:48:39.844--ServerSession(10519800)--Thread(Thread[main,5,main])--Could not initialize Validation Factory. Encountered following exception: java.lang.NoClassDefFoundError: javax/validation/Validation
[EL Finest]: 2010-06-08 17:48:39.858--ServerSession(10519800)--Thread(Thread[main,5,main])--property=eclipselink.logging.level; value=FINEST; translated value=FINEST
[EL Finest]: 2010-06-08 17:48:39.86--ServerSession(10519800)--Thread(Thread[main,5,main])--property=eclipselink.logging.level; value=FINEST; translated value=FINEST
[EL Finest]: 2010-06-08 17:48:39.861--ServerSession(10519800)--Thread(Thread[main,5,main])--property=javax.persistence.jdbc.user; value=park
[EL Finest]: 2010-06-08 17:48:39.862--ServerSession(10519800)--Thread(Thread[main,5,main])--property=javax.persistence.jdbc.password; value=xxxxxx
[EL Finest]: 2010-06-08 17:48:40.844--ServerSession(10519800)--Thread(Thread[main,5,main])--property=javax.persistence.jdbc.driver; value=org.h2.Driver
[EL Finest]: 2010-06-08 17:48:40.846--ServerSession(10519800)--Thread(Thread[main,5,main])--property=javax.persistence.jdbc.url; value=jdbc:h2:../parkDB;create=true;MODE=PostgreSQL;DB_CLOSE_DELAY=-1
[EL Finest]: 2010-06-08 17:48:40.847--ServerSession(10519800)--Thread(Thread[main,5,main])--property=eclipselink.jdbc.read-connections.min; value=1
[EL Finest]: 2010-06-08 17:48:40.848--ServerSession(10519800)--Thread(Thread[main,5,main])--property=eclipselink.jdbc.read-connections.max; value=2
[EL Info]: 2010-06-08 17:48:40.849--ServerSession(10519800)--Thread(Thread[main,5,main])--EclipseLink, version: Eclipse Persistence Services - 2.0.2.v20100323-r6872
[EL Finest]: 2010-06-08 17:48:41.702--Thread(Thread[main,5,main])--DBPlatform: org.eclipse.persistence.platform.database.HSQLPlatform, RegularExpression: (?i)hsql.*.
[EL Finest]: 2010-06-08 17:48:41.705--Thread(Thread[main,5,main])--DBPlatform: org.eclipse.persistence.platform.database.InformixPlatform, RegularExpression: (?i)informix.*.
[EL Finest]: 2010-06-08 17:48:41.706--Thread(Thread[main,5,main])--DBPlatform: org.eclipse.persistence.platform.database.PointBasePlatform, RegularExpression: (?i)pointbase.*.
[EL Finest]: 2010-06-08 17:48:41.707--Thread(Thread[main,5,main])--DBPlatform: org.eclipse.persistence.platform.database.DB2Platform, RegularExpression: (?i).*db2.*.
[EL Finest]: 2010-06-08 17:48:41.707--Thread(Thread[main,5,main])--DBPlatform: org.eclipse.persistence.platform.database.SQLServerPlatform, RegularExpression: (?i)microsoft.*.
[EL Finest]: 2010-06-08 17:48:41.708--Thread(Thread[main,5,main])--DBPlatform: org.eclipse.persistence.platform.database.PostgreSQLPlatform, RegularExpression: (?i)postgresql.*.
[EL Finest]: 2010-06-08 17:48:41.71--Thread(Thread[main,5,main])--DBPlatform: org.eclipse.persistence.platform.database.H2Platform, RegularExpression: (?i)h2.*.
[EL Fine]: 2010-06-08 17:48:41.727--Thread(Thread[main,5,main])--Detected Vendor platform: org.eclipse.persistence.platform.database.H2Platform
[EL Config]: 2010-06-08 17:48:41.77--ServerSession(10519800)--Connection(16658781)--Thread(Thread[main,5,main])--connecting(DatabaseLogin(
        platform=>H2Platform
        user name=> "park"
        datasource URL=> "jdbc:h2:../parkDB;create=true;MODE=PostgreSQL;DB_CLOSE_DELAY=-1"
))
[EL Config]: 2010-06-08 17:48:41.779--ServerSession(10519800)--Connection(20054554)--Thread(Thread[main,5,main])--Connected: jdbc:h2:../parkDB
        User: PARK
        Database: H2  Version: 1.2.131 (2010-03-05)
        Driver: H2 JDBC Driver  Version: 1.2.131 (2010-03-05)
[EL Config]: 2010-06-08 17:48:41.789--ServerSession(10519800)--Connection(2622421)--Thread(Thread[main,5,main])--connecting(DatabaseLogin(
        platform=>H2Platform
        user name=> "park"
        datasource URL=> "jdbc:h2:../parkDB;create=true;MODE=PostgreSQL;DB_CLOSE_DELAY=-1"
))
[EL Config]: 2010-06-08 17:48:41.794--ServerSession(10519800)--Connection(18061339)--Thread(Thread[main,5,main])--Connected: jdbc:h2:../parkDB
        User: PARK
        Database: H2  Version: 1.2.131 (2010-03-05)
        Driver: H2 JDBC Driver  Version: 1.2.131 (2010-03-05)
[EL Finest]: 2010-06-08 17:48:41.844--ServerSession(10519800)--Thread(Thread[main,5,main])--sequencing connected, state is Preallocation_Transaction_NoAccessor_State
[EL Finest]: 2010-06-08 17:48:41.849--ServerSession(10519800)--Thread(Thread[main,5,main])--sequence DEFAULT: preallocation size 1
[EL Info]: 2010-06-08 17:48:42.901--ServerSession(10519800)--Thread(Thread[main,5,main])--file:/home/gilberto/dev/netbeans-config/park-jpa/core/target/classes/_parkPU login successful
[EL Finer]: 2010-06-08 17:48:42.976--ServerSession(10519800)--Thread(Thread[main,5,main])--Canonical Metamodel class [park.model.Parking_] not found during initialization.
[EL Finer]: 2010-06-08 17:48:42.977--ServerSession(10519800)--Thread(Thread[main,5,main])--Canonical Metamodel class [park.model.Person_] not found during initialization.
[EL Finer]: 2010-06-08 17:48:42.979--ServerSession(10519800)--Thread(Thread[main,5,main])--Canonical Metamodel class [park.model.Vehicle_] not found during initialization.
[EL Finer]: 2010-06-08 17:48:42.98--ServerSession(10519800)--Thread(Thread[main,5,main])--Canonical Metamodel class [park.model.VehicleType_] not found during initialization.
[EL Finer]: 2010-06-08 17:48:43.002--ServerSession(10519800)--Thread(Thread[main,5,main])--Canonical Metamodel class [park.model.Stay_] not found during initialization.
[EL Finer]: 2010-06-08 17:48:43.003--ServerSession(10519800)--Thread(Thread[main,5,main])--Canonical Metamodel class [park.model.Customer_] not found during initialization.
[EL Finer]: 2010-06-08 17:48:43.005--ServerSession(10519800)--Thread(Thread[main,5,main])--Canonical Metamodel class [park.model.Employee_] not found during initialization.
[EL Finer]: 2010-06-08 17:48:43.006--ServerSession(10519800)--Thread(Thread[main,5,main])--Canonical Metamodel class [park.model.NaturalPerson_] not found during initialization.
[EL Finer]: 2010-06-08 17:48:43.008--ServerSession(10519800)--Thread(Thread[main,5,main])--Canonical Metamodel class [park.model.PriceTable_] not found during initialization.
[EL Finer]: 2010-06-08 17:48:43.009--ServerSession(10519800)--Thread(Thread[main,5,main])--Canonical Metamodel class [park.model.LegalEntity_] not found during initialization.
[EL Finest]: 2010-06-08 17:48:43.01--ServerSession(10519800)--Thread(Thread[main,5,main])--End deploying Persistence Unit parkPU; session file:/home/gilberto/dev/netbeans-config/park-jpa/core/target/classes/_parkPU; state Deployed; factoryCount 1
2010-06-08 17:48:43,988 [main] DEBUG park.model.VehicleTest - 
Getting an Vehicle by ID.

[EL Finer]: 2010-06-08 17:48:43.992--ServerSession(10519800)--Thread(Thread[main,5,main])--client acquired
[EL Finest]: 2010-06-08 17:48:44.046--UnitOfWork(2409492)--Thread(Thread[main,5,main])--Execute query ReadObjectQuery(referenceClass=Vehicle sql="SELECT license_plate, color, v_type, customer_id, price_table_id FROM park.vehicle WHERE (license_plate = ?)")
[EL Fine]: 2010-06-08 17:48:44.051--ServerSession(10519800)--Connection(20054554)--Thread(Thread[main,5,main])--SELECT license_plate, color, v_type, customer_id, price_table_id FROM park.vehicle WHERE (license_plate = ?)
        bind => [LC100]
[EL Finest]: 2010-06-08 17:48:44.094--ServerSession(10519800)--Thread(Thread[main,5,main])--Execute query ReadObjectQuery(name="vType" referenceClass=VehicleType )
[EL Fine]: 2010-06-08 17:48:44.096--ServerSession(10519800)--Connection(20054554)--Thread(Thread[main,5,main])--SELECT v_type, manufacturer, model FROM park.vehicle_type WHERE (v_type = ?)
        bind => [CAR]
[EL Finest]: 2010-06-08 17:48:44.099--ServerSession(10519800)--Thread(Thread[main,5,main])--Execute query ReadObjectQuery(name="customer" referenceClass=Customer )
[EL Fine]: 2010-06-08 17:48:44.11--ServerSession(10519800)--Connection(20054554)--Thread(Thread[main,5,main])--SELECT payment_day, person_id FROM park.customer WHERE (person_id = ?)
        bind => [1000]
[EL Finest]: 2010-06-08 17:48:44.112--ServerSession(10519800)--Thread(Thread[main,5,main])--Execute query ReadObjectQuery(name="person" referenceClass=Person )
[EL Fine]: 2010-06-08 17:48:44.114--ServerSession(10519800)--Connection(20054554)--Thread(Thread[main,5,main])--SELECT DISTINCT p_type FROM park.person WHERE (id = ?)
        bind => [1000]
[EL Fine]: 2010-06-08 17:48:44.119--ServerSession(10519800)--Connection(20054554)--Thread(Thread[main,5,main])--SELECT t0.id, t0.p_type, t0.ADDRESS, t0.NAME, t0.VERSION, t1.person_id, t1.legal_document, t1.dt_birth FROM park.person t0, park.natural_person t1 WHERE ((t0.id = ?) AND ((t1.person_id = t0.id) AND (t0.p_type = ?)))
        bind => [1000, NP]
[EL Finest]: 2010-06-08 17:48:44.143--ServerSession(10519800)--Thread(Thread[main,5,main])--Execute query ReadObjectQuery(name="priceTable" referenceClass=PriceTable )
[EL Fine]: 2010-06-08 17:48:44.144--ServerSession(10519800)--Connection(20054554)--Thread(Thread[main,5,main])--SELECT id, item, price FROM park.price_table WHERE (id = ?)
        bind => [100]
[EL Finest]: 2010-06-08 17:48:44.147--UnitOfWork(2409492)--Thread(Thread[main,5,main])--Register the existing object park.model.Vehicle[licensePlate=LC100]
[EL Finest]: 2010-06-08 17:48:44.156--UnitOfWork(2409492)--Thread(Thread[main,5,main])--Register the existing object park.model.VehicleType[V_TYPE=CAR]
[EL Finest]: 2010-06-08 17:48:44.16--UnitOfWork(2409492)--Thread(Thread[main,5,main])--Register the existing object park.model.Customer[id=1000]
[EL Finest]: 2010-06-08 17:48:44.168--UnitOfWork(2409492)--Thread(Thread[main,5,main])--Register the existing object park.model.PriceTable[id=100]
2010-06-08 17:48:44,171 [main] DEBUG park.model.VehicleTest - Object loaded: 
park.model.Vehicle[licensePlate=LC100]
[EL Finest]: 2010-06-08 17:48:44.215--UnitOfWork(2409492)--Thread(Thread[main,5,main])--Execute query ReadAllQuery(name="Vehicle.findAll" referenceClass=Vehicle sql="SELECT license_plate, color, v_type, customer_id, price_table_id FROM park.vehicle")
[EL Fine]: 2010-06-08 17:48:44.216--ServerSession(10519800)--Connection(20054554)--Thread(Thread[main,5,main])--SELECT license_plate, color, v_type, customer_id, price_table_id FROM park.vehicle
[EL Finest]: 2010-06-08 17:48:44.218--UnitOfWork(2409492)--Thread(Thread[main,5,main])--Register the existing object park.model.Vehicle[licensePlate=LC100]
[EL Finest]: 2010-06-08 17:48:44.299--ServerSession(10519800)--Thread(Thread[main,5,main])--Execute query ReadObjectQuery(name="vType" referenceClass=VehicleType )
[EL Fine]: 2010-06-08 17:48:44.3--ServerSession(10519800)--Connection(20054554)--Thread(Thread[main,5,main])--SELECT v_type, manufacturer, model FROM park.vehicle_type WHERE (v_type = ?)
        bind => [VAN]
[EL Finest]: 2010-06-08 17:48:44.302--ServerSession(10519800)--Thread(Thread[main,5,main])--Execute query ReadObjectQuery(name="customer" referenceClass=Customer )
[EL Fine]: 2010-06-08 17:48:44.303--ServerSession(10519800)--Connection(20054554)--Thread(Thread[main,5,main])--SELECT payment_day, person_id FROM park.customer WHERE (person_id = ?)
        bind => [1001]
[EL Finest]: 2010-06-08 17:48:44.304--ServerSession(10519800)--Thread(Thread[main,5,main])--Execute query ReadObjectQuery(name="person" referenceClass=Person )
[EL Fine]: 2010-06-08 17:48:44.307--ServerSession(10519800)--Connection(20054554)--Thread(Thread[main,5,main])--SELECT DISTINCT p_type FROM park.person WHERE (id = ?)
        bind => [1001]
[EL Fine]: 2010-06-08 17:48:44.309--ServerSession(10519800)--Connection(20054554)--Thread(Thread[main,5,main])--SELECT t0.id, t0.p_type, t0.ADDRESS, t0.NAME, t0.VERSION, t1.person_id, t1.legal_document, t1.dt_birth FROM park.person t0, park.natural_person t1 WHERE ((t0.id = ?) AND ((t1.person_id = t0.id) AND (t0.p_type = ?)))
        bind => [1001, NP]
[EL Finest]: 2010-06-08 17:48:44.314--ServerSession(10519800)--Thread(Thread[main,5,main])--Execute query ReadObjectQuery(name="priceTable" referenceClass=PriceTable )
[EL Fine]: 2010-06-08 17:48:44.315--ServerSession(10519800)--Connection(20054554)--Thread(Thread[main,5,main])--SELECT id, item, price FROM park.price_table WHERE (id = ?)
        bind => [101]
[EL Finest]: 2010-06-08 17:48:44.344--UnitOfWork(2409492)--Thread(Thread[main,5,main])--Register the existing object park.model.Vehicle[licensePlate=LC101]
[EL Finest]: 2010-06-08 17:48:44.345--UnitOfWork(2409492)--Thread(Thread[main,5,main])--Register the existing object park.model.VehicleType[V_TYPE=VAN]
[EL Finest]: 2010-06-08 17:48:44.346--UnitOfWork(2409492)--Thread(Thread[main,5,main])--Register the existing object park.model.Customer[id=1001]
[EL Finest]: 2010-06-08 17:48:44.347--UnitOfWork(2409492)--Thread(Thread[main,5,main])--Register the existing object park.model.PriceTable[id=101]
[EL Finest]: 2010-06-08 17:48:44.348--ServerSession(10519800)--Thread(Thread[main,5,main])--Execute query ReadObjectQuery(name="vType" referenceClass=VehicleType )
[EL Finest]: 2010-06-08 17:48:44.349--ServerSession(10519800)--Thread(Thread[main,5,main])--Execute query ReadObjectQuery(name="customer" referenceClass=Customer )
[EL Finest]: 2010-06-08 17:48:44.35--ServerSession(10519800)--Thread(Thread[main,5,main])--Execute query ReadObjectQuery(name="priceTable" referenceClass=PriceTable )
[EL Finest]: 2010-06-08 17:48:44.351--UnitOfWork(2409492)--Thread(Thread[main,5,main])--Register the existing object park.model.Vehicle[licensePlate=LC102]
[EL Finest]: 2010-06-08 17:48:44.353--UnitOfWork(2409492)--Thread(Thread[main,5,main])--Register the existing object park.model.VehicleType[V_TYPE=CAR]
[EL Finest]: 2010-06-08 17:48:44.353--UnitOfWork(2409492)--Thread(Thread[main,5,main])--Register the existing object park.model.Customer[id=1000]
[EL Finest]: 2010-06-08 17:48:44.354--UnitOfWork(2409492)--Thread(Thread[main,5,main])--Register the existing object park.model.PriceTable[id=100]
[EL Finest]: 2010-06-08 17:48:44.355--UnitOfWork(2409492)--Thread(Thread[main,5,main])--Execute query ReadObjectQuery(referenceClass=PriceTable sql="SELECT id, item, price FROM park.price_table WHERE (id = ?)")
[EL Finest]: 2010-06-08 17:48:44.356--UnitOfWork(2409492)--Thread(Thread[main,5,main])--Execute query ReadObjectQuery(referenceClass=VehicleType sql="SELECT v_type, manufacturer, model FROM park.vehicle_type WHERE (v_type = ?)")
[EL Finest]: 2010-06-08 17:48:44.357--UnitOfWork(2409492)--Thread(Thread[main,5,main])--Execute query ReadObjectQuery(referenceClass=Customer sql="SELECT payment_day, person_id FROM park.customer WHERE (person_id = ?)")
[EL Finest]: 2010-06-08 17:48:44.359--UnitOfWork(2409492)--Thread(Thread[main,5,main])--Register the existing object park.model.Customer[id=1000]
2010-06-08 17:48:44,360 [main] DEBUG park.model.VehicleTest - Customer Object loaded: 
park.model.Customer[id=1000]
2010-06-08 17:48:44,360 [main] DEBUG park.model.VehicleTest - Customer's Person Object loaded: 
null
[EL Finest]: 2010-06-08 17:48:44.361--UnitOfWork(2409492)--Thread(Thread[main,5,main])--PERSIST operation called on: park.model.Vehicle[licensePlate=LC103].
[EL Finer]: 2010-06-08 17:48:44.362--UnitOfWork(2409492)--Thread(Thread[main,5,main])--begin unit of work commit
[EL Warning]: 2010-06-08 17:48:44.444--UnitOfWork(2409492)--Thread(Thread[main,5,main])--Local Exception Stack: 
Exception [EclipseLink-7197] (Eclipse Persistence Services - 2.0.2.v20100323-r6872): org.eclipse.persistence.exceptions.ValidationException
Exception Description: Null primary key encountered in unit of work clone [park.model.Customer[id=1000]].
        at org.eclipse.persistence.exceptions.ValidationException.nullPrimaryKeyInUnitOfWorkClone(ValidationException.java:1403)
        at org.eclipse.persistence.descriptors.changetracking.DeferredChangeDetectionPolicy.calculateChanges(DeferredChangeDetectionPolicy.java:106)
        at org.eclipse.persistence.descriptors.changetracking.DeferredChangeDetectionPolicy.calculateChangesForExistingObject(DeferredChangeDetectionPolicy.java:54)
        at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.calculateChanges(UnitOfWorkImpl.java:632)
        at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitToDatabaseWithChangeSet(UnitOfWorkImpl.java:1503)
        at org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork.commitRootUnitOfWork(RepeatableWriteUnitOfWork.java:200)
        at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitAndResume(UnitOfWorkImpl.java:1139)
        at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commitInternal(EntityTransactionImpl.java:84)
        at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commit(EntityTransactionImpl.java:63)
        at park.model.VehicleTest.findAll(VehicleTest.java:123)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:592)
        at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
        at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
        at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
        at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
        at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
        at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:73)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:46)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
        at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
        at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
        at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
        at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
        at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
        at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
        at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:592)
        at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345)
        at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009)

[EL Finer]: 2010-06-08 17:48:44.452--UnitOfWork(2409492)--Thread(Thread[main,5,main])--release unit of work
[EL Finer]: 2010-06-08 17:48:44.453--ClientSession(14365489)--Thread(Thread[main,5,main])--client released
[EL Finest]: 2010-06-08 17:48:44.474--ServerSession(10519800)--Thread(Thread[main,5,main])--Begin undeploying Persistence Unit parkPU; session file:/home/gilberto/dev/netbeans-config/park-jpa/core/target/classes/_parkPU; state Deployed; factoryCount 1
[EL Finest]: 2010-06-08 17:48:44.474--ServerSession(10519800)--Thread(Thread[main,5,main])--sequencing disconnected
[EL Config]: 2010-06-08 17:48:44.475--ServerSession(10519800)--Connection(20054554)--Thread(Thread[main,5,main])--disconnect
[EL Finer]: 2010-06-08 17:48:44.476--ServerSession(10519800)--Thread(Thread[main,5,main])--initialize identitymaps
[EL Info]: 2010-06-08 17:48:44.477--ServerSession(10519800)--Thread(Thread[main,5,main])--file:/home/gilberto/dev/netbeans-config/park-jpa/core/target/classes/_parkPU logout successful
[EL Config]: 2010-06-08 17:48:44.49--ServerSession(10519800)--Connection(16658781)--Thread(Thread[main,5,main])--disconnect
[EL Config]: 2010-06-08 17:48:44.491--ServerSession(10519800)--Connection(18061339)--Thread(Thread[main,5,main])--disconnect
[EL Finest]: 2010-06-08 17:48:44.491--ServerSession(10519800)--Thread(Thread[main,5,main])--End undeploying Persistence Unit parkPU; session file:/home/gilberto/dev/netbeans-config/park-jpa/core/target/classes/_parkPU; state Undeployed; factoryCount 0
Tests run: 2, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 7.332 sec <<< FAILURE!

Results :

Tests in error: 
  findAll(park.model.VehicleTest)

Tests run: 2, Failures: 0, Errors: 1, Skipped: 0

------------------------------------------------------------------------
[ERROR]BUILD FAILURE
------------------------------------------------------------------------
There are test failures.

Please refer to /home/gilberto/dev/netbeans-config/park-jpa/core/target/surefire-reports for the individual test results.
------------------------------------------------------------------------
For more information, run Maven with the -e switch
------------------------------------------------------------------------
Total time: 18 seconds
Finished at: Tue Jun 08 17:48:45 GMT-03:00 2010
Final Memory: 11M/78M
------------------------------------------------------------------------



And the call for relationship:
        VehicleType vT = em.find(VehicleType.class, "CAR");
        Customer c = em.find(Customer.class, 1000L);
        log.debug("Customer Object loaded: \n" + c);
        log.debug("Customer's Person Object loaded: \n" + c.getPerson());
        //set relationships
        v.setCustomer(c);



Other thing, would mind to take a look at this discussion and see why I'm not getting that exception with eclipselink?

Regards,

Gilberto

[Updated on: Wed, 09 June 2010 19:12]

Report message to a moderator

Re: How to handle "null primary key encountered" exception? [message #539171 is a reply to message #538876] Wed, 09 June 2010 20:16 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
Hello,

It looks like it is querying the Person table successfully and finding a row with a type of NP indicating they are NatualPerson entities. Looking at the vehicle-dataset though, I don't see entries for a natural_person table - it looks like the vehicle-dataset is incomplete and is why the relationship is null: the query
"SELECT t0.id, t0.p_type, t0.ADDRESS, t0.NAME, t0.VERSION, t1.person_id, t1.legal_document, t1.dt_birth FROM park.person t0, park.natural_person t1 WHERE ((t0.id = ?) AND ((t1.person_id = t0.id) AND (t0.p_type = ?)))"
returns null.

Best Regards,
Chris
Re: How to handle "null primary key encountered" exception? [message #539174 is a reply to message #539171] Wed, 09 June 2010 20:51 Go to previous messageGo to next message
Gilberto Caetano de Andrade is currently offline Gilberto Caetano de AndradeFriend
Messages: 45
Registered: July 2009
Member
Great!
I wouldn't see this problem easily!

Thanks for you help.

And about this elements:
Quote:

<id name="id">
<column name="id"/>
<generated-value strategy="TABLE" generator="table_generator" pk-column-value="parking"/>
</id>


mainly pk-column-value="parking" it is not ok, right? But eclipselink doesn't show any exception.

Thanks again,

Gilberto
Re: How to handle "null primary key encountered" exception? [message #699406 is a reply to message #531645] Thu, 21 July 2011 14:03 Go to previous message
MichaelS  is currently offline MichaelS Friend
Messages: 9
Registered: July 2011
Junior Member
*edit* sorry
(no subject) [message #699413 is a reply to message #531645] Thu, 21 July 2011 14:03 Go to previous message
MichaelS  is currently offline MichaelS Friend
Messages: 9
Registered: July 2011
Junior Member
*edit* sorry
Previous Topic:eclipselink 2.3.0 on maven repo
Next Topic:(no subject)
Goto Forum:
  


Current Time: Fri Apr 19 05:43:26 GMT 2024

Powered by FUDForum. Page generated in 0.03020 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top