You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "Ulic Qeldroma (JIRA)" <ji...@apache.org> on 2008/02/01 20:21:14 UTC

[jira] Commented: (OPENJPA-494) Single Table Inheritance Strategy causes errors when reading entities from the database (discriminator problem)

    [ https://issues.apache.org/jira/browse/OPENJPA-494?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12564890#action_12564890 ] 

Russell Parry commented on OPENJPA-494:
---------------------------------------

I'm not completely sure, as I don't pretend to understand all the code involved, but this seems to be caused by the patch for OPENJPA-313.  Specifically, in the block of code starting at line 202 in org.apache.openjpa.jdbc.meta.ClassMapping you can see what changed as part of that patch.  If you set a breakpoint while running the failing test case attached here, you can see where everything looks good until we hit line 213 of ClassMapping.  At that point, the type changes from jpa.Admin to jpa.RegularUser.  It appears to me that this causes the Admin object to get loaded into the L1 cache with an incorrect oid, which causes problems later on.

cls.getDescribedType() in this same block of code returns the correct "jpa.Admin".

Changing this block of code back to the way it was before OPENJPA-313 fixes the problem described by this issue.

However, as I don't claim to fully understand the patch in question, I'm not sure if that causes other problems or if there is some other way to solve OPENJPA-313 without causing the problem shown here.

> Single Table Inheritance Strategy causes errors when reading entities from the database (discriminator problem)
> ---------------------------------------------------------------------------------------------------------------
>
>                 Key: OPENJPA-494
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-494
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 1.0.0, 1.0.1
>         Environment: Windows XP, Java 5.0 IBM
>            Reporter: Przemek Koprowski
>         Attachments: SingleTableDiscriminatorProblem.zip
>
>
> It appears that versions from 1.0 don't handle correctly discriminating objects received from the datastore when the inheritance strategy is set to SINGLE_TABLE.
> Error I receive from test cases (attached):
> <openjpa-1.0.1-r420667:592145 nonfatal user error> org.apache.openjpa.persistence.ArgumentException: Cannot load object with id "2".  Instance "jpa.Admin-2" with the same id already exists in the L1 cache.  This can occur when you assign an existing id to a new instance, and before flushing attempt to load the existing instance for that id.
> FailedObject: jpa.Admin-2
> This problem doesn't occur in OpenJPA version 0.9.7.
> Trace:
> <openjpa-1.0.1-r420667:592145 nonfatal user error> org.apache.openjpa.persistence.ArgumentException: Cannot load object with id "2".  Instance "jpa.Admin-2" with the same id already exists in the L1 cache.  This can occur when you assign an existing id to a new instance, and before flushing attempt to load the existing instance for that id.
> FailedObject: jpa.Admin-2
> 	at org.apache.openjpa.kernel.BrokerImpl$ManagedCache.add(BrokerImpl.java:4444)
> 	at org.apache.openjpa.kernel.BrokerImpl.setStateManager(BrokerImpl.java:3779)
> 	at org.apache.openjpa.kernel.StateManagerImpl.initialize(StateManagerImpl.java:303)
> 	at org.apache.openjpa.kernel.StateManagerImpl.initialize(StateManagerImpl.java:264)
> 	at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initializeState(JDBCStoreManager.java:330)
> 	at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initialize(JDBCStoreManager.java:255)
> 	at org.apache.openjpa.kernel.DelegatingStoreManager.initialize(DelegatingStoreManager.java:111)
> 	at org.apache.openjpa.kernel.ROPStoreManager.initialize(ROPStoreManager.java:57)
> 	at org.apache.openjpa.kernel.BrokerImpl.initialize(BrokerImpl.java:843)
> 	at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:801)
> 	at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:723)
> 	at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.find(JDBCStoreManager.java:748)
> 	at org.apache.openjpa.jdbc.meta.strats.RelationFieldStrategy.load(RelationFieldStrategy.java:570)
> 	at org.apache.openjpa.jdbc.meta.FieldMapping.load(FieldMapping.java:802)
> 	at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:485)
> 	at org.apache.openjpa.kernel.DelegatingStoreManager.load(DelegatingStoreManager.java:116)
> 	at org.apache.openjpa.kernel.ROPStoreManager.load(ROPStoreManager.java:78)
> 	at org.apache.openjpa.kernel.StateManagerImpl.loadFields(StateManagerImpl.java:2867)
> 	at org.apache.openjpa.kernel.StateManagerImpl.loadField(StateManagerImpl.java:2945)
> 	at org.apache.openjpa.kernel.StateManagerImpl.beforeAccessField(StateManagerImpl.java:1449)
> 	at org.apache.openjpa.kernel.StateManagerImpl.accessingField(StateManagerImpl.java:1434)
> 	at jpa.RegularUser.pcGetadmin(RegularUser.java)
> 	at jpa.RegularUser.getAdmin(RegularUser.java:16)
> 	at TestCase.testL1ProductEasier(TestCase.java:38)

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