You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "Dain Sundstrom (JIRA)" <ji...@apache.org> on 2007/08/14 21:05:30 UTC

[jira] Created: (OPENJPA-315) Unenhanced generated id field of a primitive wrapper type causes NPE

Unenhanced generated id field of a primitive wrapper type causes NPE
--------------------------------------------------------------------

                 Key: OPENJPA-315
                 URL: https://issues.apache.org/jira/browse/OPENJPA-315
             Project: OpenJPA
          Issue Type: Bug
            Reporter: Dain Sundstrom
            Priority: Critical
             Fix For: 1.0.0


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. 


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (OPENJPA-315) Unenhanced generated id field of a primitive wrapper type causes NPE

Posted by "Dain Sundstrom (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-315?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dain Sundstrom updated OPENJPA-315:
-----------------------------------

    Attachment: OPENJPA-315.patch

This patch has overrides for all the failing tests that do nothing.  These empty overrides must be removed to reproduce the bug.

> Unenhanced generated id field of a primitive wrapper type causes NPE
> --------------------------------------------------------------------
>
>                 Key: OPENJPA-315
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-315
>             Project: OpenJPA
>          Issue Type: Bug
>            Reporter: Dain Sundstrom
>            Priority: Critical
>             Fix For: 1.0.0
>
>         Attachments: OPENJPA-315.patch
>
>
> 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. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (OPENJPA-315) Unenhanced generated id field of a primitive wrapper type causes NPE

Posted by "Patrick Linskey (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OPENJPA-315?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12521271 ] 

Patrick Linskey commented on OPENJPA-315:
-----------------------------------------

> 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.

I don't follow -- are you saying that you are seeing a data corruption problem?

Note that OpenJPA will not assign an ID field until it needs to, so you should call flush() or em.getObjectId() before checking to see if an ID field has been provided.

> Unenhanced generated id field of a primitive wrapper type causes NPE
> --------------------------------------------------------------------
>
>                 Key: OPENJPA-315
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-315
>             Project: OpenJPA
>          Issue Type: Bug
>            Reporter: Dain Sundstrom
>            Priority: Critical
>             Fix For: 1.0.0
>
>         Attachments: OPENJPA-315.patch
>
>
> 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. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (OPENJPA-315) Unenhanced generated id field of a primitive wrapper type causes NPE

Posted by "Dain Sundstrom (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OPENJPA-315?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12523427 ] 

Dain Sundstrom commented on OPENJPA-315:
----------------------------------------

Sorry.  I was responding to your comment "Marking as resolved under the assumption that the IDs are properly assigned as tested elsewhere", which to me implied that you assumed there was already a test for this bug so my patch wasn't necessary.  Again, sorry.

> Unenhanced generated id field of a primitive wrapper type causes NPE
> --------------------------------------------------------------------
>
>                 Key: OPENJPA-315
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-315
>             Project: OpenJPA
>          Issue Type: Bug
>            Reporter: Dain Sundstrom
>            Priority: Critical
>             Fix For: 1.0.0
>
>         Attachments: OPENJPA-315.patch
>
>
> 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. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (OPENJPA-315) Unenhanced generated id field of a primitive wrapper type causes NPE

Posted by "Dain Sundstrom (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-315?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dain Sundstrom resolved OPENJPA-315.
------------------------------------

    Resolution: Fixed

Issue has been resolved and a test has been added

> Unenhanced generated id field of a primitive wrapper type causes NPE
> --------------------------------------------------------------------
>
>                 Key: OPENJPA-315
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-315
>             Project: OpenJPA
>          Issue Type: Bug
>            Reporter: Dain Sundstrom
>            Priority: Critical
>             Fix For: 1.0.0
>
>         Attachments: OPENJPA-315.patch
>
>
> 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. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (OPENJPA-315) Unenhanced generated id field of a primitive wrapper type causes NPE

Posted by "Patrick Linskey (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-315?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Patrick Linskey resolved OPENJPA-315.
-------------------------------------

    Resolution: Fixed

Marking as resolved under the assumption that the IDs are properly assigned as tested elsewhere.

> Unenhanced generated id field of a primitive wrapper type causes NPE
> --------------------------------------------------------------------
>
>                 Key: OPENJPA-315
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-315
>             Project: OpenJPA
>          Issue Type: Bug
>            Reporter: Dain Sundstrom
>            Priority: Critical
>             Fix For: 1.0.0
>
>         Attachments: OPENJPA-315.patch
>
>
> 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. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Reopened: (OPENJPA-315) Unenhanced generated id field of a primitive wrapper type causes NPE

Posted by "Dain Sundstrom (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-315?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dain Sundstrom reopened OPENJPA-315:
------------------------------------


> I don't follow -- are you saying that you are seeing a data corruption problem? 

No.  I said "could cause data corruption".   Any improperly loaded field in a bean could cause data corruption simply because the data isn't 100% normalized.  For example, someone could make a calculation using the primary key, which was improperly set to 0, and then store that calculation in another bean.

> Note that OpenJPA will not assign an ID field until it needs to, so you should call flush() or em.getObjectId() before checking to > see if an ID field has been provided.

Please review and apply this test.  You may have already fixed the bug when fixing the other issues I committed, but I believe this is the only test for this specific issue.   If you have already added another test for this bug, that is fine also but should be noted in this bug report for completeness.

> Unenhanced generated id field of a primitive wrapper type causes NPE
> --------------------------------------------------------------------
>
>                 Key: OPENJPA-315
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-315
>             Project: OpenJPA
>          Issue Type: Bug
>            Reporter: Dain Sundstrom
>            Priority: Critical
>             Fix For: 1.0.0
>
>         Attachments: OPENJPA-315.patch
>
>
> 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. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (OPENJPA-315) Unenhanced generated id field of a primitive wrapper type causes NPE

Posted by "Patrick Linskey (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OPENJPA-315?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12523286 ] 

Patrick Linskey commented on OPENJPA-315:
-----------------------------------------

> Please review and apply this test. 

What is "this test"? Are you referring to the patch associated with this issue? If so, how do the changes in http://svn.apache.org/viewcvs?view=rev&rev=567875 not resolve this issue? Note that if you hit the 'subversion commits' tab (or the 'all' tab) in the comments section, you'll see all commits associated with a particular JIRA issue.

Also, from a process standpoint, it's fine to create test case patches that will cause the build to fail when they are applied; presumably, the person who grabs the patch and applies it expects to use the test case to validate that a fix works.

> Unenhanced generated id field of a primitive wrapper type causes NPE
> --------------------------------------------------------------------
>
>                 Key: OPENJPA-315
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-315
>             Project: OpenJPA
>          Issue Type: Bug
>            Reporter: Dain Sundstrom
>            Priority: Critical
>             Fix For: 1.0.0
>
>         Attachments: OPENJPA-315.patch
>
>
> 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. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.