You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "Michael Vorburger (JIRA)" <ji...@apache.org> on 2009/03/04 10:17:56 UTC

[jira] Created: (OPENJPA-953) ArrayIndexOutOfBoundsException in org.apache.openjpa.util.ApplicationIds$PrimaryKeyFieldManager.retrieve

ArrayIndexOutOfBoundsException in org.apache.openjpa.util.ApplicationIds$PrimaryKeyFieldManager.retrieve
--------------------------------------------------------------------------------------------------------

                 Key: OPENJPA-953
                 URL: https://issues.apache.org/jira/browse/OPENJPA-953
             Project: OpenJPA
          Issue Type: Bug
    Affects Versions: 1.2.0
            Reporter: Michael Vorburger


As per the email thread "ArrayIndexOutOfBoundsException in org.apache.openjpa.util.ApplicationIds$PrimaryKeyFieldManager.retrieve" on users@openjpa.apache.org yesterday (see http://n2.nabble.com/ArrayIndexOutOfBoundsException-in-org.apache.openjpa.util.ApplicationIds%24PrimaryKeyFieldManager.retrieve-tt2417570.html#a2417570), there is a confirmed (Fay Wang) openjpa bug when using  application ID Identity Hierarchies as per http://openjpa.apache.org/builds/1.2.0/apache-openjpa-1.2.0/docs/manual/jpa_overview_pc_identity.html#jpa_overview_pc_identity_hierarchy, may be because I was trying to use them together with Entities as Identity Fields as per
http://openjpa.apache.org/builds/1.2.0/apache-openjpa-1.2.0/docs/manual/ref_guide_pc_oid.html#ref_guide_pc_oid_entitypk.

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


[jira] Commented: (OPENJPA-953) ArrayIndexOutOfBoundsException in org.apache.openjpa.util.ApplicationIds$PrimaryKeyFieldManager.retrieve

Posted by "Michael Vorburger (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OPENJPA-953?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12678653#action_12678653 ] 

Michael Vorburger commented on OPENJPA-953:
-------------------------------------------

The attached test case/project illustrates this problem and produces the stack trace I'll add as comment when run as mvn test:

<openjpa-1.2.0-r422266:683325 nonfatal user error> org.apache.openjpa.persistence.ArgumentException: 2  at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:814)
 at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:775)
 at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:771)
 at org.apache.openjpa.kernel.DelegatingQuery.execute(DelegatingQuery.java:517)
 at org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:254)
 at org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:293)
 at com.odcgroup.tangij.nls.LabelsDAO.getAllLabels(LabelsDAO.java:38)
 at com.odcgroup.tangij.nls.LabelsDAOTest.testLabels(LabelsDAOTest.java:34)
 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.internal.runners.TestMethod.invoke(TestMethod.java:59)
 at org.junit.internal.runners.MethodRoadie.runTestMethod(MethodRoadie.java:98)
 at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:79)
 at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:87)
 at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:77)
 at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:42)
 at org.junit.internal.runners.JUnit4ClassRunner.invokeTestMethod(JUnit4ClassRunner.java:88)
 at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
 at org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)
 at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
 at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
 at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
 at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
 at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 2  at org.apache.openjpa.util.ApplicationIds$PrimaryKeyFieldManager.retrieve(ApplicationIds.java:602)
 at org.apache.openjpa.util.ApplicationIds$PrimaryKeyFieldManager.fetchLongField(ApplicationIds.java:578)
 at com.odcgroup.tangij.domainmodel.DictLanguageLabelEntity.pcCopyKeyFieldsToObjectId(DictLanguageLabelEntity.java)
 at org.apache.openjpa.enhance.PCRegistry.copyKeyFieldsToObjectId(PCRegistry.java:172)
 at org.apache.openjpa.util.ApplicationIds.fromPKValues(ApplicationIds.java:218)
 at org.apache.openjpa.jdbc.meta.ClassMapping.getObjectId(ClassMapping.java:213)
 at org.apache.openjpa.jdbc.meta.ClassMapping.getObjectId(ClassMapping.java:150)
 at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:910)
 at org.apache.openjpa.jdbc.sql.AbstractResult.load(AbstractResult.java:278)
 at org.apache.openjpa.jdbc.sql.SelectImpl$SelectResult.load(SelectImpl.java:2391)
 at org.apache.openjpa.jdbc.sql.AbstractResult.load(AbstractResult.java:272)
 at org.apache.openjpa.jdbc.kernel.InstanceResultObjectProvider.getResultObject(InstanceResultObjectProvider.java:59)
 at org.apache.openjpa.lib.rop.EagerResultList.<init>(EagerResultList.java:36)
 at org.apache.openjpa.kernel.QueryImpl.toResult(QueryImpl.java:1228)
 at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:990)
 at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:805)
 ... 29 more

> ArrayIndexOutOfBoundsException in org.apache.openjpa.util.ApplicationIds$PrimaryKeyFieldManager.retrieve
> --------------------------------------------------------------------------------------------------------
>
>                 Key: OPENJPA-953
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-953
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 1.2.0
>            Reporter: Michael Vorburger
>
> As per the email thread "ArrayIndexOutOfBoundsException in org.apache.openjpa.util.ApplicationIds$PrimaryKeyFieldManager.retrieve" on users@openjpa.apache.org yesterday (see http://n2.nabble.com/ArrayIndexOutOfBoundsException-in-org.apache.openjpa.util.ApplicationIds%24PrimaryKeyFieldManager.retrieve-tt2417570.html#a2417570), there is a confirmed (Fay Wang) openjpa bug when using  application ID Identity Hierarchies as per http://openjpa.apache.org/builds/1.2.0/apache-openjpa-1.2.0/docs/manual/jpa_overview_pc_identity.html#jpa_overview_pc_identity_hierarchy, may be because I was trying to use them together with Entities as Identity Fields as per
> http://openjpa.apache.org/builds/1.2.0/apache-openjpa-1.2.0/docs/manual/ref_guide_pc_oid.html#ref_guide_pc_oid_entitypk.

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


[jira] Commented: (OPENJPA-953) ArrayIndexOutOfBoundsException in org.apache.openjpa.util.ApplicationIds$PrimaryKeyFieldManager.retrieve

Posted by "Michael Vorburger (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OPENJPA-953?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12683542#action_12683542 ] 

Michael Vorburger commented on OPENJPA-953:
-------------------------------------------

If possible, as a user, I would (obviously) have expected that "(b) make it work as in case (2)"... ;-)

> ArrayIndexOutOfBoundsException in org.apache.openjpa.util.ApplicationIds$PrimaryKeyFieldManager.retrieve
> --------------------------------------------------------------------------------------------------------
>
>                 Key: OPENJPA-953
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-953
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 1.2.0
>            Reporter: Michael Vorburger
>         Attachments: test-jpa2.0.zip
>
>
> As per the email thread "ArrayIndexOutOfBoundsException in org.apache.openjpa.util.ApplicationIds$PrimaryKeyFieldManager.retrieve" on users@openjpa.apache.org yesterday (see http://n2.nabble.com/ArrayIndexOutOfBoundsException-in-org.apache.openjpa.util.ApplicationIds%24PrimaryKeyFieldManager.retrieve-tt2417570.html#a2417570), there is a confirmed (Fay Wang) openjpa bug when using  application ID Identity Hierarchies as per http://openjpa.apache.org/builds/1.2.0/apache-openjpa-1.2.0/docs/manual/jpa_overview_pc_identity.html#jpa_overview_pc_identity_hierarchy, may be because I was trying to use them together with Entities as Identity Fields as per
> http://openjpa.apache.org/builds/1.2.0/apache-openjpa-1.2.0/docs/manual/ref_guide_pc_oid.html#ref_guide_pc_oid_entitypk.

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


[jira] Updated: (OPENJPA-953) ArrayIndexOutOfBoundsException in org.apache.openjpa.util.ApplicationIds$PrimaryKeyFieldManager.retrieve

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

Michael Vorburger updated OPENJPA-953:
--------------------------------------

    Attachment: test-jpa2.0.zip

> ArrayIndexOutOfBoundsException in org.apache.openjpa.util.ApplicationIds$PrimaryKeyFieldManager.retrieve
> --------------------------------------------------------------------------------------------------------
>
>                 Key: OPENJPA-953
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-953
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 1.2.0
>            Reporter: Michael Vorburger
>         Attachments: test-jpa2.0.zip
>
>
> As per the email thread "ArrayIndexOutOfBoundsException in org.apache.openjpa.util.ApplicationIds$PrimaryKeyFieldManager.retrieve" on users@openjpa.apache.org yesterday (see http://n2.nabble.com/ArrayIndexOutOfBoundsException-in-org.apache.openjpa.util.ApplicationIds%24PrimaryKeyFieldManager.retrieve-tt2417570.html#a2417570), there is a confirmed (Fay Wang) openjpa bug when using  application ID Identity Hierarchies as per http://openjpa.apache.org/builds/1.2.0/apache-openjpa-1.2.0/docs/manual/jpa_overview_pc_identity.html#jpa_overview_pc_identity_hierarchy, may be because I was trying to use them together with Entities as Identity Fields as per
> http://openjpa.apache.org/builds/1.2.0/apache-openjpa-1.2.0/docs/manual/ref_guide_pc_oid.html#ref_guide_pc_oid_entitypk.

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


[jira] Commented: (OPENJPA-953) ArrayIndexOutOfBoundsException in org.apache.openjpa.util.ApplicationIds$PrimaryKeyFieldManager.retrieve

Posted by "Michael Vorburger (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OPENJPA-953?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12678655#action_12678655 ] 

Michael Vorburger commented on OPENJPA-953:
-------------------------------------------

I actually found a work-around, for the attached test, do as follows: No DictLanguageLabelId extends DictLabelId (and no @IdClass on DictLanguageLabelEntity), and make DictLabelId not abstract.  Then add the following to the DictLabelEntity to "double map" that "object_dict_id" column (which is also mapped in the DictLanguageLabelEntity subclass), and remove the @Id from the forLanguage in DictLanguageLabelEntity:

    @Id
    @Basic(optional = false)
    @javax.persistence.Column(name = "object_dict_id", nullable = false)
    private long objectRef;

and add a public long objectRef; to the DictLabelId (with updated equals() and hashCode()).  seems to work, but is clearly a work-around for this bug...

> ArrayIndexOutOfBoundsException in org.apache.openjpa.util.ApplicationIds$PrimaryKeyFieldManager.retrieve
> --------------------------------------------------------------------------------------------------------
>
>                 Key: OPENJPA-953
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-953
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 1.2.0
>            Reporter: Michael Vorburger
>         Attachments: test-jpa2.0.zip
>
>
> As per the email thread "ArrayIndexOutOfBoundsException in org.apache.openjpa.util.ApplicationIds$PrimaryKeyFieldManager.retrieve" on users@openjpa.apache.org yesterday (see http://n2.nabble.com/ArrayIndexOutOfBoundsException-in-org.apache.openjpa.util.ApplicationIds%24PrimaryKeyFieldManager.retrieve-tt2417570.html#a2417570), there is a confirmed (Fay Wang) openjpa bug when using  application ID Identity Hierarchies as per http://openjpa.apache.org/builds/1.2.0/apache-openjpa-1.2.0/docs/manual/jpa_overview_pc_identity.html#jpa_overview_pc_identity_hierarchy, may be because I was trying to use them together with Entities as Identity Fields as per
> http://openjpa.apache.org/builds/1.2.0/apache-openjpa-1.2.0/docs/manual/ref_guide_pc_oid.html#ref_guide_pc_oid_entitypk.

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


[jira] Commented: (OPENJPA-953) ArrayIndexOutOfBoundsException in org.apache.openjpa.util.ApplicationIds$PrimaryKeyFieldManager.retrieve

Posted by "Fay Wang (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OPENJPA-953?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12678831#action_12678831 ] 

Fay Wang commented on OPENJPA-953:
----------------------------------

This problem is about the inheritance of entities and their respective IdClass. 
The following scenarios are attempted to narrow down the problem:

(1) abstract parent P (Entity) <-- child C
    parentId PId <-- childId CId
==> Exception: java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 2
	at org.apache.openjpa.util.ApplicationIds$PrimaryKeyFieldManager.retrieve
        (ApplicationIds.java:679)

(2) abstract parent P (MappedSuperClass) <-- child C
      parentId PId <-- childId CId
==> works fine

(3) concrete parent P (Entity) <-- child C
      parentId PId <-- childId CId
==> org.apache.openjpa.util.MetaDataException: Primary key fields can only be declared in base persistent classes that also declare their identity-type to be "application".
	at org.apache.openjpa.meta.ClassMetaData.validateNoPKFields
       (ClassMetaData.java:2069)

Case (1) is reported by Mike in this JIRA.  It appears that openjpa does not properly handle the IdClass inheritance when parent class is an abstract class, but annotated as Entity. The proposed solutions could be: 
(a) throw an exception as in case (3)
(b) make it work as in case (2)

Any suggestion?

> ArrayIndexOutOfBoundsException in org.apache.openjpa.util.ApplicationIds$PrimaryKeyFieldManager.retrieve
> --------------------------------------------------------------------------------------------------------
>
>                 Key: OPENJPA-953
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-953
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 1.2.0
>            Reporter: Michael Vorburger
>         Attachments: test-jpa2.0.zip
>
>
> As per the email thread "ArrayIndexOutOfBoundsException in org.apache.openjpa.util.ApplicationIds$PrimaryKeyFieldManager.retrieve" on users@openjpa.apache.org yesterday (see http://n2.nabble.com/ArrayIndexOutOfBoundsException-in-org.apache.openjpa.util.ApplicationIds%24PrimaryKeyFieldManager.retrieve-tt2417570.html#a2417570), there is a confirmed (Fay Wang) openjpa bug when using  application ID Identity Hierarchies as per http://openjpa.apache.org/builds/1.2.0/apache-openjpa-1.2.0/docs/manual/jpa_overview_pc_identity.html#jpa_overview_pc_identity_hierarchy, may be because I was trying to use them together with Entities as Identity Fields as per
> http://openjpa.apache.org/builds/1.2.0/apache-openjpa-1.2.0/docs/manual/ref_guide_pc_oid.html#ref_guide_pc_oid_entitypk.

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