Community
Participate
Working Groups
Build Identifier: 2.3.0-SNAPSHOT 20110126-22 java.lang.NullPointerException at org.eclipse.persistence.internal.sessions.DirectCollectionChangeRecord.addAdditionChange(DirectCollectionChangeRecord.java:120) at org.eclipse.persistence.internal.sessions.DirectCollectionChangeRecord.mergeRecord(DirectCollectionChangeRecord.java:318) at org.eclipse.persistence.internal.sessions.ObjectChangeSet.mergeObjectChanges(ObjectChangeSet.java:679) at org.eclipse.persistence.internal.sessions.UnitOfWorkChangeSet.mergeObjectChanges(UnitOfWorkChangeSet.java:480) at org.eclipse.persistence.internal.sessions.UnitOfWorkChangeSet.mergeUnitOfWorkChangeSet(UnitOfWorkChangeSet.java:497) at org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork.writeChanges(RepeatableWriteUnitOfWork.java:446) at org.eclipse.persistence.internal.jpa.EntityManagerImpl.flush(EntityManagerImpl.java:743) at org.eclipse.persistence.internal.jpa.EJBQueryImpl.performPreQueryFlush(EJBQueryImpl.java:1267) at org.eclipse.persistence.internal.jpa.EJBQueryImpl.executeReadQuery(EJBQueryImpl.java:431) at org.eclipse.persistence.internal.jpa.EJBQueryImpl.getResultList(EJBQueryImpl.java:739) A complete FINEST level log is available. A corresponding MySql log file is also available. Reproducible: Always Steps to Reproduce: 1.Run my database initialization application which writes MANY objects in one large transaction.
Created attachment 187805 [details] Java Logging Log file of all activity up the NPE event.
Created attachment 187806 [details] MySql log file showing all activity up the NPE event.
The same error was occurring with version 2.1.2 so I switched to 2.3.0-SNAPSHOT and the problem still occurs.
Can you provide any information about what you are doing when this occurs. ("1.Run my database initialization application which writes MANY objects in one large transaction." doesn't really help us unless we have the application) What objects are involved, how are them mapped? What does the code that triggers this look like?
I did some further debugging this morning, after making the eclipselink source available to Eclipse and found that a null was being added to the commitAddMap somewhere. Setting breakpoint on all the calls to "put()" and testing to see if the value supplied was NULL I found problem at line 316. Looking at this code at lines 314-316: if (!((DirectCollectionChangeRecord)mergeFromRecord).getCommitAddMap().containsKey(added)){ // we have not recorded a change of this type in this class before so add it this.getCommitAddMap().put(added, ((DirectCollectionChangeRecord)mergeFromRecord).getCommitAddMap().get(added)); it appears that, if the "IF" is TRUE, this will always add a NULL to the commitAddMap for the "added" object.
Please provide some instructions about what you are doing so we can recreate the problem.
BTW: I agree that the code you have posted on lines 314-316 has an issue - I am asking for any recreation steps you can provide to facilitate writing a test case that reflects your problem so we can guarantee we fix the issue you are seeing when we address this issue.
BTW: does setting the persistence unit property eclipselink.weaving.changetracking to false help?
Setting target and priority. See the following page for the meanings of these fields: http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines
(In reply to comment #8) > BTW: does setting the persistence unit property > eclipselink.weaving.changetracking to false help? It did not appear to make any difference.
The commitAddMap is used to track duplicate entries in a DirectCollection (ElementCollection containing simple types in JPA). This method is called during a merge, so I am wondering if your problem occurs in some usecase where you merge an object containing duplicates in a DirectCollectionMapping. If you are looking for database problems it might be a good idea to focus on that kind of issue. My initial look tells me that removing the if statement from the loop is probably not the correct solution. More likely, the solution is to fix the condition on the if-statement. It may be as simple as removing the "!", but we would have to recreate the problem and have a look at the results to know for sure.
moving bug to 3.1
I currently cannot recreate this problem. Please provide details of what you are doing when you see this issue. Without more detail, I will have to close this issue due to the fact that I cannot recreate it.
'Any change you are using the same EntityManager in mulple threads? That could cause this problem and is not supported by JPA.
Closing as INVALID because I cannot recreate. Please reopen if you can provide a way to recreate the problem.
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink