You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Michael Vorburger <mv...@odyssey-group.com> on 2009/03/03 20:57:35 UTC
ArrayIndexOutOfBoundsException in org.apache.openjpa.util.ApplicationIds$PrimaryKeyFieldManager.retrieve
Hello,
I'm getting a ArrayIndexOutOfBoundsException in
org.apache.openjpa.util.ApplicationIds$PrimaryKeyFieldManager.retrieve(A
pplicationIds.java:602), full stack trace below.
This occurs when I try to use 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 ...
Both of this is not JPA 1.0 spec, is it? Will this later be possible via
standard in JPA 2.0? Is there a "better" (in the sense of spec
compliant) way to do this, or a workaround or even better bug fix for
OpenJPA? Here is an attempt to sketch out the model that this occurs
with:
@javax.persistence.Entity(name = "DictLabel")
@IdClass(DictLabelId.class)
@javax.persistence.Table(name = "dict_label_vw")
@javax.persistence.Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name="entity_dict_id",
discriminatorType=DiscriminatorType.INTEGER)
public abstract class DictLabelEntity {
@Basic(optional = false)
@javax.persistence.Column(name = "name", nullable = false)
private String name;
@Id
@javax.persistence.ManyToOne(cascade = {CascadeType.PERSIST,
CascadeType.MERGE, CascadeType.REFRESH}, fetch = FetchType.LAZY,
optional = false)
@javax.persistence.JoinColumn(name = "language_dict_id", nullable =
false)
private DictLanguageEntity language;
@Id
@Basic(optional = false)
@javax.persistence.Column(name = "entity_dict_id", nullable = false)
private long entityRef;
}
@Entity(name = "DictLanguageLabel")
@IdClass(DictLanguageLabelId.class)
@DiscriminatorValue(value="1106")
public class DictLanguageLabelEntity extends DictLabelEntity {
@Id
@javax.persistence.ManyToOne(cascade = {CascadeType.PERSIST,
CascadeType.MERGE, CascadeType.REFRESH}, fetch =
FetchType.LAZY, optional = false)
@javax.persistence.JoinColumn(name = "object_dict_id", nullable =
false)
private DictLanguageEntity forLanguage;
}
public abstract class DictLabelId implements Serializable {
public long language;
public long entityRef;
// ... equals() ... hashCode() ...
}
public class DictLanguageLabelId extends DictLabelId {
public long forLanguage;
// ... equals() ... hashCode() ...
}
With this, a simple query for "SELECT l FROM DictLanguageLabel l" leads
to the exception below.
The DictLanguageEntity is another entity deliberately omitted, it's a
"standard" one with a simple @Id private long id. If this model seems
to make little sense, I have to admit that it is simplified, as in real
life there are other subclasses of DictLabelEntity, where that
object_dict_id is a ManyToOne to other entities than DictLanguageEntity.
I actually found a work-around, 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 what appears to be a bug...
Regards,
Michael
___
<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:5
17)
at org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:254)
at
org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:29
3)
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.jav
a:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
Impl.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(Met
hodRoadie.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(JUnit4Clas
sRunner.java:88)
at
org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunne
r.java:51)
at
org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.jav
a:44)
at
org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:2
7)
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(JUnit4Tes
tReference.java:38)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.ja
va:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTe
stRunner.java:460)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTe
stRunner.java:673)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRun
ner.java:386)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRu
nner.java:196)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 2
at
org.apache.openjpa.util.ApplicationIds$PrimaryKeyFieldManager.retrieve(A
pplicationIds.java:602)
at
org.apache.openjpa.util.ApplicationIds$PrimaryKeyFieldManager.fetchLongF
ield(ApplicationIds.java:578)
at
com.odcgroup.tangij.domainmodel.DictLanguageLabelEntity.pcCopyKeyFieldsT
oObjectId(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.ja
va: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.getResultObj
ect(InstanceResultObjectProvider.java:59)
at
org.apache.openjpa.lib.rop.EagerResultList.<init>(EagerResultList.java:3
6)
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
____________________________________________________________
� This email and any files transmitted with it are CONFIDENTIAL and intended
solely for the use of the individual or entity to which they are addressed.
� Any unauthorized copying, disclosure, or distribution of the material within
this email is strictly forbidden.
� Any views or opinions presented within this e-mail are solely those of the
author and do not necessarily represent those of Odyssey Financial
Technologies SA unless otherwise specifically stated.
� An electronic message is not binding on its sender. Any message referring to
a binding engagement must be confirmed in writing and duly signed.
� If you have received this email in error, please notify the sender immediately
and delete the original.
RE: ArrayIndexOutOfBoundsException in org.apache.openjpa.util.ApplicationIds$PrimaryKeyFieldManager.retrieve
Posted by Michael Vorburger <mv...@odyssey-group.com>.
https://issues.apache.org/jira/browse/OPENJPA-953, ok? - What happens next? ;-)
-----Original Message-----
From: Fay Wang [mailto:fyw300@yahoo.com]
Sent: Wednesday, March 04, 2009 6:08 AM
To: users@openjpa.apache.org
Subject: RE: ArrayIndexOutOfBoundsException in org.apache.openjpa.util.ApplicationIds$PrimaryKeyFieldManager.retrieve
Hi Mike,
This seems to be an openjpa bug. Please open a JIRA. Thanks!
-Fay
--- On Tue, 3/3/09, Fay Wang <fy...@yahoo.com> wrote:
> From: Fay Wang <fy...@yahoo.com>
> Subject: RE: ArrayIndexOutOfBoundsException in
> org.apache.openjpa.util.ApplicationIds$PrimaryKeyFieldManager.retrieve
> To: users@openjpa.apache.org
> Date: Tuesday, March 3, 2009, 3:26 PM
> Yes, with your test case, I did see the problem. The difference
> between our test cases is that in your test case, you have
> pre-created/populated the tables, while I let openjpa to create and
> populate the tables for me. Let me take a look to see why this causes
> the ArrayIndexOutOfBoundsException.
>
> Regards,
> Fay
>
>
> --- On Tue, 3/3/09, Michael Vorburger
> <mv...@odyssey-group.com> wrote:
>
> > From: Michael Vorburger
> <mv...@odyssey-group.com>
> > Subject: RE: ArrayIndexOutOfBoundsException in
> org.apache.openjpa.util.ApplicationIds$PrimaryKeyFieldManager.retrieve
> > To: users@openjpa.apache.org
> > Date: Tuesday, March 3, 2009, 2:51 PM Hello Fay,
> >
> > Uhm, I fiddled with the "infrastructure" of
> your
> > ZIP a bit (NO code changed, but Mavenized, added a missing/forgotten
> > persistence.xml, two CREATE TABLE
> and
> > INSERT INTO), and voilà, run a "mvn clean
> test"
> > on the attached updated test package and you'll
> see the
> > problem! Do you confirm?
> >
> > Regards,
> > Michael
> >
> > -----Original Message-----
> > From: Fay Wang [mailto:fyw300@yahoo.com]
> > Sent: Tuesday, March 03, 2009 10:21 PM
> > To: users@openjpa.apache.org
> > Subject: Re: ArrayIndexOutOfBoundsException in
> >
> org.apache.openjpa.util.ApplicationIds$PrimaryKeyFieldManager.retrieve
> >
> > Hmmm. I could not reproduce the error using your
> domain
> > model in 1.2.0 and trunk. Attached is the test case.
> Could
> > you run it to see it passes?
> >
> > Regards,
> > Fay
> >
> >
> >
> > --- On Tue, 3/3/09, Michael Vorburger <mv...@odyssey-group.com>
> > wrote:
> >
> > > From: Michael Vorburger
> > <mv...@odyssey-group.com>
> > > Subject: ArrayIndexOutOfBoundsException in
> > >
> >
> org.apache.openjpa.util.ApplicationIds$PrimaryKeyFieldManager.retrieve
> > > To: users@openjpa.apache.org
> > > Date: Tuesday, March 3, 2009, 11:57 AM Hello,
> > >
> > > I'm getting a ArrayIndexOutOfBoundsException
> in
> > >
> >
> org.apache.openjpa.util.ApplicationIds$PrimaryKeyFieldManager.retrieve
> > > (A pplicationIds.java:602), full stack trace
> below.
> > >
> > > This occurs when I try to use application ID
> Identity
> > Hierarchies as
> > > per
> > >
> >
> http://openjpa.apache.org/builds/1.2.0/apache-openjpa-1.2.0/docs/manua
> > > l/
> >
> 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/manua
> > > l/
> ref_guide_pc_oid.html#ref_guide_pc_oid_entitypk ...
> > >
> > > Both of this is not JPA 1.0 spec, is it? Will
> this
> > later be possible
> > > via standard in JPA 2.0? Is there a
> "better"
> > (in the sense of spec
> > > compliant) way to do this, or a workaround or
> even
> > better bug fix for
> > > OpenJPA? Here is an attempt to sketch out the
> model
> > that this occurs
> > > with:
> > >
> > > @javax.persistence.Entity(name =
> > "DictLabel")
> > > @IdClass(DictLabelId.class)
> > > @javax.persistence.Table(name =
> > "dict_label_vw")
> > > @javax.persistence.Inheritance(strategy =
> > > InheritanceType.SINGLE_TABLE)
> > >
> @DiscriminatorColumn(name="entity_dict_id",
> > > discriminatorType=DiscriminatorType.INTEGER)
> > > public abstract class DictLabelEntity {
> > >
> > > @Basic(optional = false)
> > > @javax.persistence.Column(name =
> "name",
> > nullable = false) private
> > > String name;
> > >
> > > @Id
> > > @javax.persistence.ManyToOne(cascade =
> > {CascadeType.PERSIST,
> > > CascadeType.MERGE, CascadeType.REFRESH}, fetch
> =
> > FetchType.LAZY,
> > > optional = false)
> @javax.persistence.JoinColumn(name
> > =
> > > "language_dict_id", nullable =
> > > false)
> > > private DictLanguageEntity language;
> > >
> > > @Id
> > > @Basic(optional = false)
> > > @javax.persistence.Column(name =
> > > "entity_dict_id", nullable = false) private long entityRef; }
> > >
> > > @Entity(name = "DictLanguageLabel")
> > > @IdClass(DictLanguageLabelId.class)
> > > @DiscriminatorValue(value="1106")
> > > public class DictLanguageLabelEntity extends
> > DictLabelEntity {
> > >
> > > @Id
> > > @javax.persistence.ManyToOne(cascade =
> > {CascadeType.PERSIST,
> > > CascadeType.MERGE,
> CascadeType.REFRESH},
> > fetch =
> > > FetchType.LAZY, optional = false)
> > > @javax.persistence.JoinColumn(name =
> > "object_dict_id", nullable =
> > > false)
> > > private DictLanguageEntity forLanguage; }
> > >
> > > public abstract class DictLabelId implements
> > Serializable {
> > > public long language;
> > > public long entityRef;
> > > // ... equals() ... hashCode() ...
> > > }
> > >
> > > public class DictLanguageLabelId extends
> DictLabelId {
> > > public long forLanguage;
> > > // ... equals() ... hashCode() ...
> > > }
> > >
> > > With this, a simple query for "SELECT l FROM
> > DictLanguageLabel l"
> > > leads to the exception below.
> > >
> > > The DictLanguageEntity is another entity
> deliberately
> > omitted, it's a
> > > "standard" one with a simple @Id
> private
> > long id.
> > > If this model seems
> > > to make little sense, I have to admit that it is
> > simplified, as in
> > > real life there are other subclasses of
> > DictLabelEntity, where that
> > > object_dict_id is a ManyToOne to other entities
> than
> > > DictLanguageEntity.
> > >
> > > I actually found a work-around, 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 what appears to be a bug...
> > >
> > > Regards,
> > > Michael
> > >
> > > ___
> > > <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
> > > :5
> > > 17)
> > > at
> > >
> >
> org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:254)
> > > at
> > >
> >
> org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:
> > > 29
> > > 3)
> > > 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.j
> > > av
> > > a:39)
> > > at
> > >
> >
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccess
> > > or
> > > Impl.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(M
> > > et
> > > hodRoadie.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(JUnit4Cl
> > > as
> > > sRunner.java:88)
> > > at
> > >
> >
> org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRun
> > > ne
> > > r.java:51)
> > > at
> > >
> >
> org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.j
> > > av
> > > a:44)
> > > at
> > >
> >
> org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java
> > > :2
> > > 7)
> > > at
> > >
> >
> org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:3
> > > 7)
> > > at
> > >
> >
> org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:
> > > 42)
> > > at
> > >
> >
> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4T
> > > es
> > > tReference.java:38)
> > > at
> > >
> >
> org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.
> > > ja
> > > va:38)
> > > at
> > >
> >
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(Remote
> > > Te
> > > stRunner.java:460)
> > > at
> > >
> >
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(Remote
> > > Te
> > > stRunner.java:673)
> > > at
> > >
> >
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestR
> > > un
> > > ner.java:386)
> > > at
> > >
> >
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTest
> > > Ru
> > > nner.java:196)
> > > Caused by:
> java.lang.ArrayIndexOutOfBoundsException: 2
> > at
> > >
> >
> org.apache.openjpa.util.ApplicationIds$PrimaryKeyFieldManager.retrieve
> > > (A
> > > pplicationIds.java:602)
> > > at
> > >
> >
> org.apache.openjpa.util.ApplicationIds$PrimaryKeyFieldManager.fetchLon
> > > gF
> > > ield(ApplicationIds.java:578)
> > > at
> > >
> >
> com.odcgroup.tangij.domainmodel.DictLanguageLabelEntity.pcCopyKeyField
> > > sT
> > > oObjectId(DictLanguageLabelEntity.java)
> > > at
> > >
> >
> org.apache.openjpa.enhance.PCRegistry.copyKeyFieldsToObjectId(PCRegist
> > > ry
> > > .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.
> > > ja
> > > va:910)
> > > at
> > >
> >
> org.apache.openjpa.jdbc.sql.AbstractResult.load(AbstractResult.java:27
> > > 8)
> > > at
> > >
> >
> org.apache.openjpa.jdbc.sql.SelectImpl$SelectResult.load(SelectImpl.ja
> > > va
> > > :2391)
> > > at
> > >
> >
> org.apache.openjpa.jdbc.sql.AbstractResult.load(AbstractResult.java:27
> > > 2)
> > > at
> > >
> >
> org.apache.openjpa.jdbc.kernel.InstanceResultObjectProvider.getResultO
> > > bj
> > > ect(InstanceResultObjectProvider.java:59)
> > > at
> > >
> >
> org.apache.openjpa.lib.rop.EagerResultList.<init>(EagerResultList.java
> > > :3
> > > 6)
> > > 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
> > >
> > >
> > >
> >
> ____________________________________________________________
> > >
> > > * This email and any files transmitted with it
> are
> > CONFIDENTIAL and
> > > intended
> > > solely for the use of the individual or entity
> to
> > which they are
> > > addressed.
> > > * Any unauthorized copying, disclosure, or
> > distribution of the
> > > material within
> > > this email is strictly forbidden.
> > > * Any views or opinions presented within this
> e-mail
> > are solely those
> > > of the
> > > author and do not necessarily represent those
> of
> > Odyssey Financial
> > > Technologies SA unless otherwise specifically
> stated.
> > > * An electronic message is not binding on its
> sender.
> > Any message
> > > referring to
> > > a binding engagement must be confirmed in
> writing
> > and duly signed.
> > > * If you have received this email in error,
> please
> > notify the sender
> > > immediately
> > > and delete the original.
> >
> >
> >
> >
> >
> ____________________________________________________________
> >
> > * This email and any files transmitted with it are CONFIDENTIAL and
> > intended
> > solely for the use of the individual or entity to
> which
> > they are addressed.
> > * Any unauthorized copying, disclosure, or
> distribution
> > of the material within
> > this email is strictly forbidden.
> > * Any views or opinions presented within this e-mail
> are
> > solely those of the
> > author and do not necessarily represent those of
> Odyssey
> > Financial
> > Technologies SA unless otherwise specifically stated.
> > * An electronic message is not binding on its
> sender. Any
> > message referring to
> > a binding engagement must be confirmed in writing
> and
> > duly signed.
> > * If you have received this email in error, please
> notify
> > the sender immediately
> > and delete the original.
____________________________________________________________
This email and any files transmitted with it are CONFIDENTIAL and intended
solely for the use of the individual or entity to which they are addressed.
Any unauthorized copying, disclosure, or distribution of the material within
this email is strictly forbidden.
Any views or opinions presented within this e-mail are solely those of the
author and do not necessarily represent those of Odyssey Financial
Technologies SA unless otherwise specifically stated.
An electronic message is not binding on its sender. Any message referring to
a binding engagement must be confirmed in writing and duly signed.
If you have received this email in error, please notify the sender immediately
and delete the original.
RE: ArrayIndexOutOfBoundsException in org.apache.openjpa.util.ApplicationIds$PrimaryKeyFieldManager.retrieve
Posted by Fay Wang <fy...@yahoo.com>.
Hi Mike,
This seems to be an openjpa bug. Please open a JIRA. Thanks!
-Fay
--- On Tue, 3/3/09, Fay Wang <fy...@yahoo.com> wrote:
> From: Fay Wang <fy...@yahoo.com>
> Subject: RE: ArrayIndexOutOfBoundsException in org.apache.openjpa.util.ApplicationIds$PrimaryKeyFieldManager.retrieve
> To: users@openjpa.apache.org
> Date: Tuesday, March 3, 2009, 3:26 PM
> Yes, with your test case, I did see the problem. The
> difference between our test cases is that in your test case,
> you have pre-created/populated the tables, while I let
> openjpa to create and populate the tables for me. Let me
> take a look to see why this causes the
> ArrayIndexOutOfBoundsException.
>
> Regards,
> Fay
>
>
> --- On Tue, 3/3/09, Michael Vorburger
> <mv...@odyssey-group.com> wrote:
>
> > From: Michael Vorburger
> <mv...@odyssey-group.com>
> > Subject: RE: ArrayIndexOutOfBoundsException in
> org.apache.openjpa.util.ApplicationIds$PrimaryKeyFieldManager.retrieve
> > To: users@openjpa.apache.org
> > Date: Tuesday, March 3, 2009, 2:51 PM
> > Hello Fay,
> >
> > Uhm, I fiddled with the "infrastructure" of
> your
> > ZIP a bit (NO code changed, but Mavenized, added a
> > missing/forgotten persistence.xml, two CREATE TABLE
> and
> > INSERT INTO), and voilà, run a "mvn clean
> test"
> > on the attached updated test package and you'll
> see the
> > problem! Do you confirm?
> >
> > Regards,
> > Michael
> >
> > -----Original Message-----
> > From: Fay Wang [mailto:fyw300@yahoo.com]
> > Sent: Tuesday, March 03, 2009 10:21 PM
> > To: users@openjpa.apache.org
> > Subject: Re: ArrayIndexOutOfBoundsException in
> >
> org.apache.openjpa.util.ApplicationIds$PrimaryKeyFieldManager.retrieve
> >
> > Hmmm. I could not reproduce the error using your
> domain
> > model in 1.2.0 and trunk. Attached is the test case.
> Could
> > you run it to see it passes?
> >
> > Regards,
> > Fay
> >
> >
> >
> > --- On Tue, 3/3/09, Michael Vorburger
> > <mv...@odyssey-group.com> wrote:
> >
> > > From: Michael Vorburger
> > <mv...@odyssey-group.com>
> > > Subject: ArrayIndexOutOfBoundsException in
> > >
> >
> org.apache.openjpa.util.ApplicationIds$PrimaryKeyFieldManager.retrieve
> > > To: users@openjpa.apache.org
> > > Date: Tuesday, March 3, 2009, 11:57 AM Hello,
> > >
> > > I'm getting a ArrayIndexOutOfBoundsException
> in
> > >
> >
> org.apache.openjpa.util.ApplicationIds$PrimaryKeyFieldManager.retrieve
> > > (A pplicationIds.java:602), full stack trace
> below.
> > >
> > > This occurs when I try to use application ID
> Identity
> > Hierarchies as
> > > per
> > >
> >
> http://openjpa.apache.org/builds/1.2.0/apache-openjpa-1.2.0/docs/manua
> > > l/
> >
> 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/manua
> > > l/
> ref_guide_pc_oid.html#ref_guide_pc_oid_entitypk ...
> > >
> > > Both of this is not JPA 1.0 spec, is it? Will
> this
> > later be possible
> > > via standard in JPA 2.0? Is there a
> "better"
> > (in the sense of spec
> > > compliant) way to do this, or a workaround or
> even
> > better bug fix for
> > > OpenJPA? Here is an attempt to sketch out the
> model
> > that this occurs
> > > with:
> > >
> > > @javax.persistence.Entity(name =
> > "DictLabel")
> > > @IdClass(DictLabelId.class)
> > > @javax.persistence.Table(name =
> > "dict_label_vw")
> > > @javax.persistence.Inheritance(strategy =
> > > InheritanceType.SINGLE_TABLE)
> > >
> @DiscriminatorColumn(name="entity_dict_id",
> > > discriminatorType=DiscriminatorType.INTEGER)
> > > public abstract class DictLabelEntity {
> > >
> > > @Basic(optional = false)
> > > @javax.persistence.Column(name =
> "name",
> > nullable = false) private
> > > String name;
> > >
> > > @Id
> > > @javax.persistence.ManyToOne(cascade =
> > {CascadeType.PERSIST,
> > > CascadeType.MERGE, CascadeType.REFRESH}, fetch
> =
> > FetchType.LAZY,
> > > optional = false)
> @javax.persistence.JoinColumn(name
> > =
> > > "language_dict_id", nullable =
> > > false)
> > > private DictLanguageEntity language;
> > >
> > > @Id
> > > @Basic(optional = false)
> > > @javax.persistence.Column(name =
> > > "entity_dict_id", nullable = false)
> > > private long entityRef;
> > > }
> > >
> > > @Entity(name = "DictLanguageLabel")
> > > @IdClass(DictLanguageLabelId.class)
> > > @DiscriminatorValue(value="1106")
> > > public class DictLanguageLabelEntity extends
> > DictLabelEntity {
> > >
> > > @Id
> > > @javax.persistence.ManyToOne(cascade =
> > {CascadeType.PERSIST,
> > > CascadeType.MERGE,
> CascadeType.REFRESH},
> > fetch =
> > > FetchType.LAZY, optional = false)
> > > @javax.persistence.JoinColumn(name =
> > "object_dict_id", nullable =
> > > false)
> > > private DictLanguageEntity forLanguage; }
> > >
> > > public abstract class DictLabelId implements
> > Serializable {
> > > public long language;
> > > public long entityRef;
> > > // ... equals() ... hashCode() ...
> > > }
> > >
> > > public class DictLanguageLabelId extends
> DictLabelId {
> > > public long forLanguage;
> > > // ... equals() ... hashCode() ...
> > > }
> > >
> > > With this, a simple query for "SELECT l FROM
> > DictLanguageLabel l"
> > > leads to the exception below.
> > >
> > > The DictLanguageEntity is another entity
> deliberately
> > omitted, it's a
> > > "standard" one with a simple @Id
> private
> > long id.
> > > If this model seems
> > > to make little sense, I have to admit that it is
> > simplified, as in
> > > real life there are other subclasses of
> > DictLabelEntity, where that
> > > object_dict_id is a ManyToOne to other entities
> than
> > > DictLanguageEntity.
> > >
> > > I actually found a work-around, 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 what appears to be a bug...
> > >
> > > Regards,
> > > Michael
> > >
> > > ___
> > > <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
> > > :5
> > > 17)
> > > at
> > >
> >
> org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:254)
> > > at
> > >
> >
> org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:
> > > 29
> > > 3)
> > > 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.j
> > > av
> > > a:39)
> > > at
> > >
> >
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccess
> > > or
> > > Impl.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(M
> > > et
> > > hodRoadie.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(JUnit4Cl
> > > as
> > > sRunner.java:88)
> > > at
> > >
> >
> org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRun
> > > ne
> > > r.java:51)
> > > at
> > >
> >
> org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.j
> > > av
> > > a:44)
> > > at
> > >
> >
> org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java
> > > :2
> > > 7)
> > > at
> > >
> >
> org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:3
> > > 7)
> > > at
> > >
> >
> org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:
> > > 42)
> > > at
> > >
> >
> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4T
> > > es
> > > tReference.java:38)
> > > at
> > >
> >
> org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.
> > > ja
> > > va:38)
> > > at
> > >
> >
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(Remote
> > > Te
> > > stRunner.java:460)
> > > at
> > >
> >
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(Remote
> > > Te
> > > stRunner.java:673)
> > > at
> > >
> >
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestR
> > > un
> > > ner.java:386)
> > > at
> > >
> >
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTest
> > > Ru
> > > nner.java:196)
> > > Caused by:
> java.lang.ArrayIndexOutOfBoundsException: 2
> > at
> > >
> >
> org.apache.openjpa.util.ApplicationIds$PrimaryKeyFieldManager.retrieve
> > > (A
> > > pplicationIds.java:602)
> > > at
> > >
> >
> org.apache.openjpa.util.ApplicationIds$PrimaryKeyFieldManager.fetchLon
> > > gF
> > > ield(ApplicationIds.java:578)
> > > at
> > >
> >
> com.odcgroup.tangij.domainmodel.DictLanguageLabelEntity.pcCopyKeyField
> > > sT
> > > oObjectId(DictLanguageLabelEntity.java)
> > > at
> > >
> >
> org.apache.openjpa.enhance.PCRegistry.copyKeyFieldsToObjectId(PCRegist
> > > ry
> > > .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.
> > > ja
> > > va:910)
> > > at
> > >
> >
> org.apache.openjpa.jdbc.sql.AbstractResult.load(AbstractResult.java:27
> > > 8)
> > > at
> > >
> >
> org.apache.openjpa.jdbc.sql.SelectImpl$SelectResult.load(SelectImpl.ja
> > > va
> > > :2391)
> > > at
> > >
> >
> org.apache.openjpa.jdbc.sql.AbstractResult.load(AbstractResult.java:27
> > > 2)
> > > at
> > >
> >
> org.apache.openjpa.jdbc.kernel.InstanceResultObjectProvider.getResultO
> > > bj
> > > ect(InstanceResultObjectProvider.java:59)
> > > at
> > >
> >
> org.apache.openjpa.lib.rop.EagerResultList.<init>(EagerResultList.java
> > > :3
> > > 6)
> > > 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
> > >
> > >
> > >
> >
> ____________________________________________________________
> > >
> > > * This email and any files transmitted with it
> are
> > CONFIDENTIAL and
> > > intended
> > > solely for the use of the individual or entity
> to
> > which they are
> > > addressed.
> > > * Any unauthorized copying, disclosure, or
> > distribution of the
> > > material within
> > > this email is strictly forbidden.
> > > * Any views or opinions presented within this
> e-mail
> > are solely those
> > > of the
> > > author and do not necessarily represent those
> of
> > Odyssey Financial
> > > Technologies SA unless otherwise specifically
> stated.
> > > * An electronic message is not binding on its
> sender.
> > Any message
> > > referring to
> > > a binding engagement must be confirmed in
> writing
> > and duly signed.
> > > * If you have received this email in error,
> please
> > notify the sender
> > > immediately
> > > and delete the original.
> >
> >
> >
> >
> >
> ____________________________________________________________
> >
> > • This email and any files transmitted with it are
> > CONFIDENTIAL and intended
> > solely for the use of the individual or entity to
> which
> > they are addressed.
> > • Any unauthorized copying, disclosure, or
> distribution
> > of the material within
> > this email is strictly forbidden.
> > • Any views or opinions presented within this e-mail
> are
> > solely those of the
> > author and do not necessarily represent those of
> Odyssey
> > Financial
> > Technologies SA unless otherwise specifically stated.
> > • An electronic message is not binding on its
> sender. Any
> > message referring to
> > a binding engagement must be confirmed in writing
> and
> > duly signed.
> > • If you have received this email in error, please
> notify
> > the sender immediately
> > and delete the original.
RE: ArrayIndexOutOfBoundsException in org.apache.openjpa.util.ApplicationIds$PrimaryKeyFieldManager.retrieve
Posted by Fay Wang <fy...@yahoo.com>.
Yes, with your test case, I did see the problem. The difference between our test cases is that in your test case, you have pre-created/populated the tables, while I let openjpa to create and populate the tables for me. Let me take a look to see why this causes the ArrayIndexOutOfBoundsException.
Regards,
Fay
--- On Tue, 3/3/09, Michael Vorburger <mv...@odyssey-group.com> wrote:
> From: Michael Vorburger <mv...@odyssey-group.com>
> Subject: RE: ArrayIndexOutOfBoundsException in org.apache.openjpa.util.ApplicationIds$PrimaryKeyFieldManager.retrieve
> To: users@openjpa.apache.org
> Date: Tuesday, March 3, 2009, 2:51 PM
> Hello Fay,
>
> Uhm, I fiddled with the "infrastructure" of your
> ZIP a bit (NO code changed, but Mavenized, added a
> missing/forgotten persistence.xml, two CREATE TABLE and
> INSERT INTO), and voilà, run a "mvn clean test"
> on the attached updated test package and you'll see the
> problem! Do you confirm?
>
> Regards,
> Michael
>
> -----Original Message-----
> From: Fay Wang [mailto:fyw300@yahoo.com]
> Sent: Tuesday, March 03, 2009 10:21 PM
> To: users@openjpa.apache.org
> Subject: Re: ArrayIndexOutOfBoundsException in
> org.apache.openjpa.util.ApplicationIds$PrimaryKeyFieldManager.retrieve
>
> Hmmm. I could not reproduce the error using your domain
> model in 1.2.0 and trunk. Attached is the test case. Could
> you run it to see it passes?
>
> Regards,
> Fay
>
>
>
> --- On Tue, 3/3/09, Michael Vorburger
> <mv...@odyssey-group.com> wrote:
>
> > From: Michael Vorburger
> <mv...@odyssey-group.com>
> > Subject: ArrayIndexOutOfBoundsException in
> >
> org.apache.openjpa.util.ApplicationIds$PrimaryKeyFieldManager.retrieve
> > To: users@openjpa.apache.org
> > Date: Tuesday, March 3, 2009, 11:57 AM Hello,
> >
> > I'm getting a ArrayIndexOutOfBoundsException in
> >
> org.apache.openjpa.util.ApplicationIds$PrimaryKeyFieldManager.retrieve
> > (A pplicationIds.java:602), full stack trace below.
> >
> > This occurs when I try to use application ID Identity
> Hierarchies as
> > per
> >
> http://openjpa.apache.org/builds/1.2.0/apache-openjpa-1.2.0/docs/manua
> > l/
> 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/manua
> > l/ ref_guide_pc_oid.html#ref_guide_pc_oid_entitypk ...
> >
> > Both of this is not JPA 1.0 spec, is it? Will this
> later be possible
> > via standard in JPA 2.0? Is there a "better"
> (in the sense of spec
> > compliant) way to do this, or a workaround or even
> better bug fix for
> > OpenJPA? Here is an attempt to sketch out the model
> that this occurs
> > with:
> >
> > @javax.persistence.Entity(name =
> "DictLabel")
> > @IdClass(DictLabelId.class)
> > @javax.persistence.Table(name =
> "dict_label_vw")
> > @javax.persistence.Inheritance(strategy =
> > InheritanceType.SINGLE_TABLE)
> > @DiscriminatorColumn(name="entity_dict_id",
> > discriminatorType=DiscriminatorType.INTEGER)
> > public abstract class DictLabelEntity {
> >
> > @Basic(optional = false)
> > @javax.persistence.Column(name = "name",
> nullable = false) private
> > String name;
> >
> > @Id
> > @javax.persistence.ManyToOne(cascade =
> {CascadeType.PERSIST,
> > CascadeType.MERGE, CascadeType.REFRESH}, fetch =
> FetchType.LAZY,
> > optional = false) @javax.persistence.JoinColumn(name
> =
> > "language_dict_id", nullable =
> > false)
> > private DictLanguageEntity language;
> >
> > @Id
> > @Basic(optional = false)
> > @javax.persistence.Column(name =
> > "entity_dict_id", nullable = false)
> > private long entityRef;
> > }
> >
> > @Entity(name = "DictLanguageLabel")
> > @IdClass(DictLanguageLabelId.class)
> > @DiscriminatorValue(value="1106")
> > public class DictLanguageLabelEntity extends
> DictLabelEntity {
> >
> > @Id
> > @javax.persistence.ManyToOne(cascade =
> {CascadeType.PERSIST,
> > CascadeType.MERGE, CascadeType.REFRESH},
> fetch =
> > FetchType.LAZY, optional = false)
> > @javax.persistence.JoinColumn(name =
> "object_dict_id", nullable =
> > false)
> > private DictLanguageEntity forLanguage; }
> >
> > public abstract class DictLabelId implements
> Serializable {
> > public long language;
> > public long entityRef;
> > // ... equals() ... hashCode() ...
> > }
> >
> > public class DictLanguageLabelId extends DictLabelId {
> > public long forLanguage;
> > // ... equals() ... hashCode() ...
> > }
> >
> > With this, a simple query for "SELECT l FROM
> DictLanguageLabel l"
> > leads to the exception below.
> >
> > The DictLanguageEntity is another entity deliberately
> omitted, it's a
> > "standard" one with a simple @Id private
> long id.
> > If this model seems
> > to make little sense, I have to admit that it is
> simplified, as in
> > real life there are other subclasses of
> DictLabelEntity, where that
> > object_dict_id is a ManyToOne to other entities than
> > DictLanguageEntity.
> >
> > I actually found a work-around, 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 what appears to be a bug...
> >
> > Regards,
> > Michael
> >
> > ___
> > <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
> > :5
> > 17)
> > at
> >
> org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:254)
> > at
> >
> org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:
> > 29
> > 3)
> > 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.j
> > av
> > a:39)
> > at
> >
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccess
> > or
> > Impl.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(M
> > et
> > hodRoadie.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(JUnit4Cl
> > as
> > sRunner.java:88)
> > at
> >
> org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRun
> > ne
> > r.java:51)
> > at
> >
> org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.j
> > av
> > a:44)
> > at
> >
> org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java
> > :2
> > 7)
> > at
> >
> org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:3
> > 7)
> > at
> >
> org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:
> > 42)
> > at
> >
> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4T
> > es
> > tReference.java:38)
> > at
> >
> org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.
> > ja
> > va:38)
> > at
> >
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(Remote
> > Te
> > stRunner.java:460)
> > at
> >
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(Remote
> > Te
> > stRunner.java:673)
> > at
> >
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestR
> > un
> > ner.java:386)
> > at
> >
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTest
> > Ru
> > nner.java:196)
> > Caused by: java.lang.ArrayIndexOutOfBoundsException: 2
> at
> >
> org.apache.openjpa.util.ApplicationIds$PrimaryKeyFieldManager.retrieve
> > (A
> > pplicationIds.java:602)
> > at
> >
> org.apache.openjpa.util.ApplicationIds$PrimaryKeyFieldManager.fetchLon
> > gF
> > ield(ApplicationIds.java:578)
> > at
> >
> com.odcgroup.tangij.domainmodel.DictLanguageLabelEntity.pcCopyKeyField
> > sT
> > oObjectId(DictLanguageLabelEntity.java)
> > at
> >
> org.apache.openjpa.enhance.PCRegistry.copyKeyFieldsToObjectId(PCRegist
> > ry
> > .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.
> > ja
> > va:910)
> > at
> >
> org.apache.openjpa.jdbc.sql.AbstractResult.load(AbstractResult.java:27
> > 8)
> > at
> >
> org.apache.openjpa.jdbc.sql.SelectImpl$SelectResult.load(SelectImpl.ja
> > va
> > :2391)
> > at
> >
> org.apache.openjpa.jdbc.sql.AbstractResult.load(AbstractResult.java:27
> > 2)
> > at
> >
> org.apache.openjpa.jdbc.kernel.InstanceResultObjectProvider.getResultO
> > bj
> > ect(InstanceResultObjectProvider.java:59)
> > at
> >
> org.apache.openjpa.lib.rop.EagerResultList.<init>(EagerResultList.java
> > :3
> > 6)
> > 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
> >
> >
> >
> ____________________________________________________________
> >
> > * This email and any files transmitted with it are
> CONFIDENTIAL and
> > intended
> > solely for the use of the individual or entity to
> which they are
> > addressed.
> > * Any unauthorized copying, disclosure, or
> distribution of the
> > material within
> > this email is strictly forbidden.
> > * Any views or opinions presented within this e-mail
> are solely those
> > of the
> > author and do not necessarily represent those of
> Odyssey Financial
> > Technologies SA unless otherwise specifically stated.
> > * An electronic message is not binding on its sender.
> Any message
> > referring to
> > a binding engagement must be confirmed in writing
> and duly signed.
> > * If you have received this email in error, please
> notify the sender
> > immediately
> > and delete the original.
>
>
>
>
> ____________________________________________________________
>
> • This email and any files transmitted with it are
> CONFIDENTIAL and intended
> solely for the use of the individual or entity to which
> they are addressed.
> • Any unauthorized copying, disclosure, or distribution
> of the material within
> this email is strictly forbidden.
> • Any views or opinions presented within this e-mail are
> solely those of the
> author and do not necessarily represent those of Odyssey
> Financial
> Technologies SA unless otherwise specifically stated.
> • An electronic message is not binding on its sender. Any
> message referring to
> a binding engagement must be confirmed in writing and
> duly signed.
> • If you have received this email in error, please notify
> the sender immediately
> and delete the original.
RE: ArrayIndexOutOfBoundsException in org.apache.openjpa.util.ApplicationIds$PrimaryKeyFieldManager.retrieve
Posted by Michael Vorburger <mv...@odyssey-group.com>.
Hello Fay,
Uhm, I fiddled with the "infrastructure" of your ZIP a bit (NO code changed, but Mavenized, added a missing/forgotten persistence.xml, two CREATE TABLE and INSERT INTO), and voilà, run a "mvn clean test" on the attached updated test package and you'll see the problem! Do you confirm?
Regards,
Michael
-----Original Message-----
From: Fay Wang [mailto:fyw300@yahoo.com]
Sent: Tuesday, March 03, 2009 10:21 PM
To: users@openjpa.apache.org
Subject: Re: ArrayIndexOutOfBoundsException in org.apache.openjpa.util.ApplicationIds$PrimaryKeyFieldManager.retrieve
Hmmm. I could not reproduce the error using your domain model in 1.2.0 and trunk. Attached is the test case. Could you run it to see it passes?
Regards,
Fay
--- On Tue, 3/3/09, Michael Vorburger <mv...@odyssey-group.com> wrote:
> From: Michael Vorburger <mv...@odyssey-group.com>
> Subject: ArrayIndexOutOfBoundsException in
> org.apache.openjpa.util.ApplicationIds$PrimaryKeyFieldManager.retrieve
> To: users@openjpa.apache.org
> Date: Tuesday, March 3, 2009, 11:57 AM Hello,
>
> I'm getting a ArrayIndexOutOfBoundsException in
> org.apache.openjpa.util.ApplicationIds$PrimaryKeyFieldManager.retrieve
> (A pplicationIds.java:602), full stack trace below.
>
> This occurs when I try to use application ID Identity Hierarchies as
> per
> http://openjpa.apache.org/builds/1.2.0/apache-openjpa-1.2.0/docs/manua
> l/ 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/manua
> l/ ref_guide_pc_oid.html#ref_guide_pc_oid_entitypk ...
>
> Both of this is not JPA 1.0 spec, is it? Will this later be possible
> via standard in JPA 2.0? Is there a "better" (in the sense of spec
> compliant) way to do this, or a workaround or even better bug fix for
> OpenJPA? Here is an attempt to sketch out the model that this occurs
> with:
>
> @javax.persistence.Entity(name = "DictLabel")
> @IdClass(DictLabelId.class)
> @javax.persistence.Table(name = "dict_label_vw")
> @javax.persistence.Inheritance(strategy =
> InheritanceType.SINGLE_TABLE)
> @DiscriminatorColumn(name="entity_dict_id",
> discriminatorType=DiscriminatorType.INTEGER)
> public abstract class DictLabelEntity {
>
> @Basic(optional = false)
> @javax.persistence.Column(name = "name", nullable = false) private
> String name;
>
> @Id
> @javax.persistence.ManyToOne(cascade = {CascadeType.PERSIST,
> CascadeType.MERGE, CascadeType.REFRESH}, fetch = FetchType.LAZY,
> optional = false) @javax.persistence.JoinColumn(name =
> "language_dict_id", nullable =
> false)
> private DictLanguageEntity language;
>
> @Id
> @Basic(optional = false)
> @javax.persistence.Column(name =
> "entity_dict_id", nullable = false)
> private long entityRef;
> }
>
> @Entity(name = "DictLanguageLabel")
> @IdClass(DictLanguageLabelId.class)
> @DiscriminatorValue(value="1106")
> public class DictLanguageLabelEntity extends DictLabelEntity {
>
> @Id
> @javax.persistence.ManyToOne(cascade = {CascadeType.PERSIST,
> CascadeType.MERGE, CascadeType.REFRESH}, fetch =
> FetchType.LAZY, optional = false)
> @javax.persistence.JoinColumn(name = "object_dict_id", nullable =
> false)
> private DictLanguageEntity forLanguage; }
>
> public abstract class DictLabelId implements Serializable {
> public long language;
> public long entityRef;
> // ... equals() ... hashCode() ...
> }
>
> public class DictLanguageLabelId extends DictLabelId {
> public long forLanguage;
> // ... equals() ... hashCode() ...
> }
>
> With this, a simple query for "SELECT l FROM DictLanguageLabel l"
> leads to the exception below.
>
> The DictLanguageEntity is another entity deliberately omitted, it's a
> "standard" one with a simple @Id private long id.
> If this model seems
> to make little sense, I have to admit that it is simplified, as in
> real life there are other subclasses of DictLabelEntity, where that
> object_dict_id is a ManyToOne to other entities than
> DictLanguageEntity.
>
> I actually found a work-around, 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 what appears to be a bug...
>
> Regards,
> Michael
>
> ___
> <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
> :5
> 17)
> at
> org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:254)
> at
> org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:
> 29
> 3)
> 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.j
> av
> a:39)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccess
> or
> Impl.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(M
> et
> hodRoadie.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(JUnit4Cl
> as
> sRunner.java:88)
> at
> org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRun
> ne
> r.java:51)
> at
> org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.j
> av
> a:44)
> at
> org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java
> :2
> 7)
> at
> org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:3
> 7)
> at
> org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:
> 42)
> at
> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4T
> es
> tReference.java:38)
> at
> org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.
> ja
> va:38)
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(Remote
> Te
> stRunner.java:460)
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(Remote
> Te
> stRunner.java:673)
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestR
> un
> ner.java:386)
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTest
> Ru
> nner.java:196)
> Caused by: java.lang.ArrayIndexOutOfBoundsException: 2 at
> org.apache.openjpa.util.ApplicationIds$PrimaryKeyFieldManager.retrieve
> (A
> pplicationIds.java:602)
> at
> org.apache.openjpa.util.ApplicationIds$PrimaryKeyFieldManager.fetchLon
> gF
> ield(ApplicationIds.java:578)
> at
> com.odcgroup.tangij.domainmodel.DictLanguageLabelEntity.pcCopyKeyField
> sT
> oObjectId(DictLanguageLabelEntity.java)
> at
> org.apache.openjpa.enhance.PCRegistry.copyKeyFieldsToObjectId(PCRegist
> ry
> .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.
> ja
> va:910)
> at
> org.apache.openjpa.jdbc.sql.AbstractResult.load(AbstractResult.java:27
> 8)
> at
> org.apache.openjpa.jdbc.sql.SelectImpl$SelectResult.load(SelectImpl.ja
> va
> :2391)
> at
> org.apache.openjpa.jdbc.sql.AbstractResult.load(AbstractResult.java:27
> 2)
> at
> org.apache.openjpa.jdbc.kernel.InstanceResultObjectProvider.getResultO
> bj
> ect(InstanceResultObjectProvider.java:59)
> at
> org.apache.openjpa.lib.rop.EagerResultList.<init>(EagerResultList.java
> :3
> 6)
> 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
>
>
> ____________________________________________________________
>
> * This email and any files transmitted with it are CONFIDENTIAL and
> intended
> solely for the use of the individual or entity to which they are
> addressed.
> * Any unauthorized copying, disclosure, or distribution of the
> material within
> this email is strictly forbidden.
> * Any views or opinions presented within this e-mail are solely those
> of the
> author and do not necessarily represent those of Odyssey Financial
> Technologies SA unless otherwise specifically stated.
> * An electronic message is not binding on its sender. Any message
> referring to
> a binding engagement must be confirmed in writing and duly signed.
> * If you have received this email in error, please notify the sender
> immediately
> and delete the original.
____________________________________________________________
This email and any files transmitted with it are CONFIDENTIAL and intended
solely for the use of the individual or entity to which they are addressed.
Any unauthorized copying, disclosure, or distribution of the material within
this email is strictly forbidden.
Any views or opinions presented within this e-mail are solely those of the
author and do not necessarily represent those of Odyssey Financial
Technologies SA unless otherwise specifically stated.
An electronic message is not binding on its sender. Any message referring to
a binding engagement must be confirmed in writing and duly signed.
If you have received this email in error, please notify the sender immediately
and delete the original.
Re: ArrayIndexOutOfBoundsException in org.apache.openjpa.util.ApplicationIds$PrimaryKeyFieldManager.retrieve
Posted by Fay Wang <fy...@yahoo.com>.
Hmmm. I could not reproduce the error using your domain model in 1.2.0 and trunk. Attached is the test case. Could you run it to see it passes?
Regards,
Fay
--- On Tue, 3/3/09, Michael Vorburger <mv...@odyssey-group.com> wrote:
> From: Michael Vorburger <mv...@odyssey-group.com>
> Subject: ArrayIndexOutOfBoundsException in org.apache.openjpa.util.ApplicationIds$PrimaryKeyFieldManager.retrieve
> To: users@openjpa.apache.org
> Date: Tuesday, March 3, 2009, 11:57 AM
> Hello,
>
> I'm getting a ArrayIndexOutOfBoundsException in
> org.apache.openjpa.util.ApplicationIds$PrimaryKeyFieldManager.retrieve(A
> pplicationIds.java:602), full stack trace below.
>
> This occurs when I try to use 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 ...
>
> Both of this is not JPA 1.0 spec, is it? Will this later be
> possible via
> standard in JPA 2.0? Is there a "better" (in the
> sense of spec
> compliant) way to do this, or a workaround or even better
> bug fix for
> OpenJPA? Here is an attempt to sketch out the model that
> this occurs
> with:
>
> @javax.persistence.Entity(name = "DictLabel")
> @IdClass(DictLabelId.class)
> @javax.persistence.Table(name = "dict_label_vw")
> @javax.persistence.Inheritance(strategy =
> InheritanceType.SINGLE_TABLE)
> @DiscriminatorColumn(name="entity_dict_id",
> discriminatorType=DiscriminatorType.INTEGER)
> public abstract class DictLabelEntity {
>
> @Basic(optional = false)
> @javax.persistence.Column(name = "name",
> nullable = false)
> private String name;
>
> @Id
> @javax.persistence.ManyToOne(cascade =
> {CascadeType.PERSIST,
> CascadeType.MERGE, CascadeType.REFRESH}, fetch =
> FetchType.LAZY,
> optional = false)
> @javax.persistence.JoinColumn(name =
> "language_dict_id", nullable =
> false)
> private DictLanguageEntity language;
>
> @Id
> @Basic(optional = false)
> @javax.persistence.Column(name =
> "entity_dict_id", nullable = false)
> private long entityRef;
> }
>
> @Entity(name = "DictLanguageLabel")
> @IdClass(DictLanguageLabelId.class)
> @DiscriminatorValue(value="1106")
> public class DictLanguageLabelEntity extends
> DictLabelEntity {
>
> @Id
> @javax.persistence.ManyToOne(cascade =
> {CascadeType.PERSIST,
> CascadeType.MERGE, CascadeType.REFRESH}, fetch
> =
> FetchType.LAZY, optional = false)
> @javax.persistence.JoinColumn(name =
> "object_dict_id", nullable =
> false)
> private DictLanguageEntity forLanguage;
> }
>
> public abstract class DictLabelId implements Serializable {
> public long language;
> public long entityRef;
> // ... equals() ... hashCode() ...
> }
>
> public class DictLanguageLabelId extends DictLabelId {
> public long forLanguage;
> // ... equals() ... hashCode() ...
> }
>
> With this, a simple query for "SELECT l FROM
> DictLanguageLabel l" leads
> to the exception below.
>
> The DictLanguageEntity is another entity deliberately
> omitted, it's a
> "standard" one with a simple @Id private long id.
> If this model seems
> to make little sense, I have to admit that it is
> simplified, as in real
> life there are other subclasses of DictLabelEntity, where
> that
> object_dict_id is a ManyToOne to other entities than
> DictLanguageEntity.
>
> I actually found a work-around, 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 what appears to be a bug...
>
> Regards,
> Michael
>
> ___
> <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:5
> 17)
> at
> org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:254)
> at
> org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:29
> 3)
> 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.jav
> a:39)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
> Impl.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(Met
> hodRoadie.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(JUnit4Clas
> sRunner.java:88)
> at
> org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunne
> r.java:51)
> at
> org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.jav
> a:44)
> at
> org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:2
> 7)
> 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(JUnit4Tes
> tReference.java:38)
> at
> org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.ja
> va:38)
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTe
> stRunner.java:460)
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTe
> stRunner.java:673)
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRun
> ner.java:386)
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRu
> nner.java:196)
> Caused by: java.lang.ArrayIndexOutOfBoundsException: 2
> at
> org.apache.openjpa.util.ApplicationIds$PrimaryKeyFieldManager.retrieve(A
> pplicationIds.java:602)
> at
> org.apache.openjpa.util.ApplicationIds$PrimaryKeyFieldManager.fetchLongF
> ield(ApplicationIds.java:578)
> at
> com.odcgroup.tangij.domainmodel.DictLanguageLabelEntity.pcCopyKeyFieldsT
> oObjectId(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.ja
> va: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.getResultObj
> ect(InstanceResultObjectProvider.java:59)
> at
> org.apache.openjpa.lib.rop.EagerResultList.<init>(EagerResultList.java:3
> 6)
> 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
>
>
> ____________________________________________________________
>
> • This email and any files transmitted with it are
> CONFIDENTIAL and intended
> solely for the use of the individual or entity to which
> they are addressed.
> • Any unauthorized copying, disclosure, or distribution
> of the material within
> this email is strictly forbidden.
> • Any views or opinions presented within this e-mail are
> solely those of the
> author and do not necessarily represent those of Odyssey
> Financial
> Technologies SA unless otherwise specifically stated.
> • An electronic message is not binding on its sender. Any
> message referring to
> a binding engagement must be confirmed in writing and
> duly signed.
> • If you have received this email in error, please notify
> the sender immediately
> and delete the original.