Issue Details (XML | Word | Printable)

Key: OPENJPA-315
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Critical Critical
Assignee: Unassigned
Reporter: Dain Sundstrom
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
OpenJPA

Unenhanced generated id field of a primitive wrapper type causes NPE

Created: 14/Aug/07 07:04 PM   Updated: 13/May/09 10:06 PM
Return to search
Component/s: UnenhancedClasses
Affects Version/s: None
Fix Version/s: 1.0.0

Time Tracking:
Not Specified

File Attachments:
  Size
Text File Licensed for inclusion in ASF works OPENJPA-315.patch 2007-08-14 07:07 PM Dain Sundstrom 10 kB
Issue Links:
Blocker
 

Resolution Date: 29/Aug/07 01:26 AM


 Description  « Hide
Unenhanced generated id field of a primitive wrapper type causes NPE because the field value is null. This bug only occurs when the id field is an object type as primitive fields are automatically initialized to 0. I believe this is a critical bug because when using a primitive field the system appears to work but the id field is always 0 which could cause data corruption. The following stack trace shows the bug:

<openjpa-0.0.0-r420667:564688M nonfatal general error> org.apache.openjpa.persistence.PersistenceException: null
at org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2437)
at org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2251)
at org.apache.openjpa.kernel.DelegatingBroker.persist(DelegatingBroker.java:1010)
at org.apache.openjpa.persistence.EntityManagerImpl.persist(EntityManagerImpl.java:541)
at org.apache.openjpa.enhance.AbstractUnenhancedClassTest.getObjectIdHelper(AbstractUnenhancedClassTest.java:134)
at org.apache.openjpa.enhance.AbstractUnenhancedClassTest.testGetObjectIdOnOpenJPAType(AbstractUnenhancedClassTest.java:115)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:40)
Caused by: java.lang.NullPointerException
at org.apache.openjpa.util.ApplicationIds.fromPKValues(ApplicationIds.java:152)
at org.apache.openjpa.enhance.ReflectingPersistenceCapable.pcNewObjectIdInstance(ReflectingPersistenceCapable.java:257)
at org.apache.openjpa.util.ApplicationIds.create(ApplicationIds.java:384)
at org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2405)
... 23 more

The attached patch reproduces this bug. The patch is a clone of TestUnenhancedFieldAccess that simply changes the id field to type Integer.


 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order