Issues mapping numerous tables to a single entity?

2009-12-04 Thread KARR, DAVID (ATTCINW)
In Hibernate and JPA, I'm used to looking at scenarios where I map a
single table to a single entity, along with relationships to other
entities with various multiplicities.

I'm now looking at a situation where I'm going to need to develop a JPA
mapping for a pretty large collection of entities, where the largest
entities actually are defined by an aggregation of numerous tables (like
20).  What provisions are there in JPA and OpenJPA for mapping multiple
tables to a single entity?  I'm not talking about an inheritance
hierarchy, but where the numerous tables are linked by a common PK
value.


RE: Why does the enhancer create a PROTECTE no-args constructor by default?

2009-12-04 Thread KARR, DAVID (ATTCINW)
> -Original Message-
> From: Michael Dick [mailto:michael.d.d...@gmail.com]
> Sent: Friday, December 04, 2009 1:54 PM
> To: users@openjpa.apache.org
> Subject: Re: Why does the enhancer create a PROTECTE no-args
> constructor by default?
> 
> Hi David,
> 
> The JVM will create a no-arg constructor if you have no other
> constructors.
> The spec requires a no-arg constructor so that the persistence
provider
> can
> create an empty instance. OpenJPA uses it via some tricky generated
> code
> (bytecode insertion).
> 
> As for why it's protected instead of public I presume the original
devs
> thought it was safer to restrict access to the generated constructor.
> It
> isn't documented in the manual, but you could go diving in
> PCEnhancer.java
> (which generates the constructor) and see if there are any comments
> that
> shed some light on the rationale.

Nope, not a word.  The "enhanceClass()" generates the constructor as
public if it's externalizable, private if it's final (which is odd, as I
thought you couldn't have final persistent classes), and protected
otherwise.  No indication why.  There was a comment about making it
public if the class was externalizable, but nothing else.

> On Fri, Dec 4, 2009 at 2:55 PM, KARR, DAVID (ATTCINW)
> wrote:
> 
> > > -Original Message-
> > > From: Rick Curtis [mailto:curti...@gmail.com]
> > > Sent: Friday, December 04, 2009 12:31 PM
> > > To: users@openjpa.apache.org
> > > Subject: Re: Why does the enhancer create a PROTECTE no-args
> > > constructor by default?
> > >
> > > David-
> > >
> > > Per the JPA spec --
> > >
> > > The entity class must have a no-arg constructor. The entity class
> may
> > > have
> > > other constructors as well.
> > > The no-arg constructor must be public or protected.
> > >
> > > ...so if your Entity doesn't have one, OpenJPA will do it for you.
> >
> > Ok, I'll phrase the question again, and perhaps I can make it more
> > obvious this time.
> >
> > Why does the enhancer create a PROTECTED no-args constructor, and
not
> a
> > PUBLIC one?
> >
> > If it was going to create a PUBLIC constructor, there'd be
absolutely
> no
> > point to this, because that's exactly what the JVM does.  If the
> > enhancer had a good reason to create a PROTECTED constructor instead
> of
> > a PUBLIC one, then I can see why the enhancer would do this, but I
> still
> > see no obvious reason to create a PROTECTED constructor.
> >
> > Is that clearer now?
> >
> 
> > > --
> > > Thanks,
> > > Rick
> > >
> > > On Fri, Dec 4, 2009 at 1:29 PM, KARR, DAVID (ATTCINW)
> > > wrote:
> > >
> > > > I'm reading the OpenJPA doc, and I see that the enhancer creates
> a
> > > > protected no-args constructor if there is no public one.  Why
> > exactly
> > > > does it do that?  What is the point of creating a protected
> > > constructor
> > > > instead of letting the JVM create the public one?  The doc only
> says
> > > > that it does this, not why.
> > > >
> >


Re: Why does the enhancer create a PROTECTE no-args constructor by default?

2009-12-04 Thread Michael Dick
Hi David,

The JVM will create a no-arg constructor if you have no other constructors.
The spec requires a no-arg constructor so that the persistence provider can
create an empty instance. OpenJPA uses it via some tricky generated code
(bytecode insertion).

As for why it's protected instead of public I presume the original devs
thought it was safer to restrict access to the generated constructor. It
isn't documented in the manual, but you could go diving in PCEnhancer.java
(which generates the constructor) and see if there are any comments that
shed some light on the rationale.

-mike

On Fri, Dec 4, 2009 at 2:55 PM, KARR, DAVID (ATTCINW) wrote:

> > -Original Message-
> > From: Rick Curtis [mailto:curti...@gmail.com]
> > Sent: Friday, December 04, 2009 12:31 PM
> > To: users@openjpa.apache.org
> > Subject: Re: Why does the enhancer create a PROTECTE no-args
> > constructor by default?
> >
> > David-
> >
> > Per the JPA spec --
> >
> > The entity class must have a no-arg constructor. The entity class may
> > have
> > other constructors as well.
> > The no-arg constructor must be public or protected.
> >
> > ...so if your Entity doesn't have one, OpenJPA will do it for you.
>
> Ok, I'll phrase the question again, and perhaps I can make it more
> obvious this time.
>
> Why does the enhancer create a PROTECTED no-args constructor, and not a
> PUBLIC one?
>
> If it was going to create a PUBLIC constructor, there'd be absolutely no
> point to this, because that's exactly what the JVM does.  If the
> enhancer had a good reason to create a PROTECTED constructor instead of
> a PUBLIC one, then I can see why the enhancer would do this, but I still
> see no obvious reason to create a PROTECTED constructor.
>
> Is that clearer now?
>

> > --
> > Thanks,
> > Rick
> >
> > On Fri, Dec 4, 2009 at 1:29 PM, KARR, DAVID (ATTCINW)
> > wrote:
> >
> > > I'm reading the OpenJPA doc, and I see that the enhancer creates a
> > > protected no-args constructor if there is no public one.  Why
> exactly
> > > does it do that?  What is the point of creating a protected
> > constructor
> > > instead of letting the JVM create the public one?  The doc only says
> > > that it does this, not why.
> > >
>


Can a "native" query get/set the timezone from a Calendar?

2009-12-04 Thread KARR, DAVID (ATTCINW)
I noticed in the doc that OpenJPA doesn't support storing or retrieving
the timezone value, just the Date portion, even for a TIMESTAMPTZ column
(although it doesn't mention that last part).

The doc for EclipseLink says something similar, but it simply says that
you have to use "native SQL" in order to get/set the timezone with
Calendar.

I can't imagine any reason why native queries in EclipseLink would be
able to do this, but native queries in OpenJPA couldn't.  Is there a
good reason why a statement to this effect didn't make it into the
OpenJPA doc (besides "we didn't think of it")?


RE: Why does the enhancer create a PROTECTE no-args constructor by default?

2009-12-04 Thread KARR, DAVID (ATTCINW)
> -Original Message-
> From: Rick Curtis [mailto:curti...@gmail.com]
> Sent: Friday, December 04, 2009 12:31 PM
> To: users@openjpa.apache.org
> Subject: Re: Why does the enhancer create a PROTECTE no-args
> constructor by default?
> 
> David-
> 
> Per the JPA spec --
> 
> The entity class must have a no-arg constructor. The entity class may
> have
> other constructors as well.
> The no-arg constructor must be public or protected.
> 
> ...so if your Entity doesn't have one, OpenJPA will do it for you.

Ok, I'll phrase the question again, and perhaps I can make it more
obvious this time.

Why does the enhancer create a PROTECTED no-args constructor, and not a
PUBLIC one?

If it was going to create a PUBLIC constructor, there'd be absolutely no
point to this, because that's exactly what the JVM does.  If the
enhancer had a good reason to create a PROTECTED constructor instead of
a PUBLIC one, then I can see why the enhancer would do this, but I still
see no obvious reason to create a PROTECTED constructor.

Is that clearer now?

> --
> Thanks,
> Rick
> 
> On Fri, Dec 4, 2009 at 1:29 PM, KARR, DAVID (ATTCINW)
> wrote:
> 
> > I'm reading the OpenJPA doc, and I see that the enhancer creates a
> > protected no-args constructor if there is no public one.  Why
exactly
> > does it do that?  What is the point of creating a protected
> constructor
> > instead of letting the JVM create the public one?  The doc only says
> > that it does this, not why.
> >


Re: Why does the enhancer create a PROTECTE no-args constructor by default?

2009-12-04 Thread Rick Curtis
David-

Per the JPA spec --

The entity class must have a no-arg constructor. The entity class may have
other constructors as well.
The no-arg constructor must be public or protected.

...so if your Entity doesn't have one, OpenJPA will do it for you.
-- 
Thanks,
Rick

On Fri, Dec 4, 2009 at 1:29 PM, KARR, DAVID (ATTCINW) wrote:

> I'm reading the OpenJPA doc, and I see that the enhancer creates a
> protected no-args constructor if there is no public one.  Why exactly
> does it do that?  What is the point of creating a protected constructor
> instead of letting the JVM create the public one?  The doc only says
> that it does this, not why.
>


Why does the enhancer create a PROTECTE no-args constructor by default?

2009-12-04 Thread KARR, DAVID (ATTCINW)
I'm reading the OpenJPA doc, and I see that the enhancer creates a
protected no-args constructor if there is no public one.  Why exactly
does it do that?  What is the point of creating a protected constructor
instead of letting the JVM create the public one?  The doc only says
that it does this, not why.


Re: openJPA with EJB3 MySQL on WAS7

2009-12-04 Thread Kevin Sutter
Hi,
Kind of strange.  OpenJPA has many, many examples of persistent operations
against various databases, including MySQL.  All without the behavior that
you are seeing.  A couple of things jump out at me...

o  How is your dao constructor setting the values on the fields?  Since you
are using property-based access, all access to these fields need to be
through the getter/setter methods.

o  I noticed that your getter/setter methods are "synchronized final".
OpenJPA states support for "final" methods, so that should work okay.  But,
why are you using synchronized?  I don't see why this should make a
difference, but it's overhead that should not be necessary.

o  And, when is the transaction completing?  The em.persist() method does
not push items to the database.  The enclosing transaction needs to
complete, or a flush needs to happen, to push the data to the database.

o  How are you verifying that the records are getting created?  You see
actual records (rows) getting created with new generated IDs, but none of
the other fields are filled in?  You could turn on SQL trace from OpenJPA
and see what SQL is actually being generated.  This would help confirm
whether the problem is in the application space or the database space.

Let's start with these questions before going further.
Thanks,
Kevin

On Fri, Dec 4, 2009 at 9:32 AM, kpsuk  wrote:

>
> Having a little trouble with openJPA persiting with MySQL, whilst new rows
> are being created for each em.persist(dao) the rows are bring populated
> with
> 'NULL' values for each column!
>
> I get no error in my logs and debugging shows that the property values are
> there right upto the em.persist(dao) line of code.
>
> DAO
> @Entity
> @Table(name = "tbl_user_details")
> public class UserRegistrationDao implements java.io.Serializable {
>private int id;
>private String firstname;
>private String surname;
>private String email;
>@Id
>@GeneratedValue(strategy = GenerationType.IDENTITY)
>@Column(name="id")
>public int getId() {
>return this.id;
>}
>public void setId(int id) {
>this.id = id;
>}
>
>@Basic
>@Column(name="firstname")
>public synchronized final String getFirstname() {
>return this.firstname;
>}
>public synchronized final void setFirstname(String firstname) {
>this.firstname = firstname;
>}
>
>@Basic
>@Column(name="surname")
>public synchronized final String getSurname() {
>return this.surname;
>}
>public synchronized final void setSurname(String surname) {
>this.surname = surname;
>}
>
>@Basic
>@Column(name="email")
>public synchronized final String getEmail() {
>return this.email;
>}
>public synchronized final void setEmail(String email) {
>this.email = email;
>}
> }
>
> Bean
>@PersistenceContext(unitName = "users", type =
> PersistenceContextType.EXTENDED)
>private EntityManager _em;
>@Override
>public boolean create(Map args) {
>UserRegistrationDao dao = new UserRegistrationDao(args);
>_em.persist(dao);  // *** upto here values are present ***
>
>
> persistence.xml
>
>
>
> org.apache.openjpa.persistence.PersistenceProviderImpl
>jdbc/users
>
>com.project1.business.dao.UserRegistrationDao
>
>
> value="jdbc:mysql://localhost:3306/users"/>
> value="com.mysql.jdbc.Driver"/>
> value="root"/>
> value="rootpass123"/>
>
>
>
>
> --
> View this message in context:
> http://n2.nabble.com/openJPA-with-EJB3-MySQL-on-WAS7-tp4113103p4113103.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>


RE: openJPA with EJB3 MySQL on WAS7

2009-12-04 Thread Russell Collins
Just a quick question.  Is the table already created or are you trying to use 
OpenJPA to create the table?

-Original Message-
From: kpsuk [mailto:keithsec...@yahoo.co.uk] 
Sent: Friday, December 04, 2009 9:32 AM
To: users@openjpa.apache.org
Subject: openJPA with EJB3 MySQL on WAS7


Having a little trouble with openJPA persiting with MySQL, whilst new rows
are being created for each em.persist(dao) the rows are bring populated with
'NULL' values for each column!

I get no error in my logs and debugging shows that the property values are
there right upto the em.persist(dao) line of code.

DAO
@Entity
@Table(name = "tbl_user_details")
public class UserRegistrationDao implements java.io.Serializable {
private int id;
private String firstname;
private String surname;
private String email;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name="id")
public int getId() {
return this.id;
}
public void setId(int id) {
this.id = id;
}

@Basic
@Column(name="firstname")
public synchronized final String getFirstname() {
return this.firstname;
}
public synchronized final void setFirstname(String firstname) {
this.firstname = firstname;
}

@Basic  
@Column(name="surname")
public synchronized final String getSurname() {
return this.surname;
}
public synchronized final void setSurname(String surname) {
this.surname = surname;
}

@Basic  
@Column(name="email")
public synchronized final String getEmail() {
return this.email;
}
public synchronized final void setEmail(String email) {
this.email = email;
}
}

Bean
@PersistenceContext(unitName = "users", type =
PersistenceContextType.EXTENDED)
private EntityManager _em;
@Override
public boolean create(Map args) {
UserRegistrationDao dao = new UserRegistrationDao(args);
_em.persist(dao);  // *** upto here values are present ***


persistence.xml



org.apache.openjpa.persistence.PersistenceProviderImpl 
jdbc/users

com.project1.business.dao.UserRegistrationDao










-- 
View this message in context: 
http://n2.nabble.com/openJPA-with-EJB3-MySQL-on-WAS7-tp4113103p4113103.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.


Re: Setter not working for detached object

2009-12-04 Thread Rick Curtis
Tao -

Can you post a simple testcase demonstrating the problem?

-- 
Thanks,
Rick

On Thu, Dec 3, 2009 at 3:38 PM, Javatao  wrote:

>
> Hi, Experts,
>
> I am having an issue with detached object in OpenJPA.
>
> Setter method of relationship field does not work.
> Setter method of primitive field works fine.
>
> Here is an example
> ===
> ...
> Foo foo = entityManager.find(Foo.class, 1);
> Bar foo = entityManager.find(Bar.class, 2);
> ...
> entityManager.close();
> ...
>
>
> foo.setName("newNameFoo");
> bar.setName("newNameBar");
> foo.setBar(bar);
> System.out.println(foo.getName());
> System.out.println(bar.getName());
> System.out.println(foo.getBar());
> =
>
> Here is the output:
>
> newNameFoo
> newNameBar
> null
>
>
> This is so wierd!
>
> Any idea?
>
> Many thanks in advance!
>
> Tao
>
>
> --
> View this message in context:
> http://n2.nabble.com/Setter-not-working-for-detached-object-tp4109048p4109048.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>


openJPA with EJB3 MySQL on WAS7

2009-12-04 Thread kpsuk

Having a little trouble with openJPA persiting with MySQL, whilst new rows
are being created for each em.persist(dao) the rows are bring populated with
'NULL' values for each column!

I get no error in my logs and debugging shows that the property values are
there right upto the em.persist(dao) line of code.

DAO
@Entity
@Table(name = "tbl_user_details")
public class UserRegistrationDao implements java.io.Serializable {
private int id;
private String firstname;
private String surname;
private String email;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name="id")
public int getId() {
return this.id;
}
public void setId(int id) {
this.id = id;
}

@Basic
@Column(name="firstname")
public synchronized final String getFirstname() {
return this.firstname;
}
public synchronized final void setFirstname(String firstname) {
this.firstname = firstname;
}

@Basic  
@Column(name="surname")
public synchronized final String getSurname() {
return this.surname;
}
public synchronized final void setSurname(String surname) {
this.surname = surname;
}

@Basic  
@Column(name="email")
public synchronized final String getEmail() {
return this.email;
}
public synchronized final void setEmail(String email) {
this.email = email;
}
}

Bean
@PersistenceContext(unitName = "users", type =
PersistenceContextType.EXTENDED)
private EntityManager _em;
@Override
public boolean create(Map args) {
UserRegistrationDao dao = new UserRegistrationDao(args);
_em.persist(dao);  // *** upto here values are present ***


persistence.xml



org.apache.openjpa.persistence.PersistenceProviderImpl 
jdbc/users

com.project1.business.dao.UserRegistrationDao










-- 
View this message in context: 
http://n2.nabble.com/openJPA-with-EJB3-MySQL-on-WAS7-tp4113103p4113103.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.


Re: Out of bounds exception with fetch plan

2009-12-04 Thread Daryl Stultz
On Fri, Dec 4, 2009 at 3:40 AM, Srinivasan Krishnamoorthy <
srinivasan.kr...@live.com> wrote:

>
> Hi Daryl,
>  Did you get a solution to this problem... We are also facing exactly the
> same issue..
>
> No, my work around was to not use fetch plans and use "left join fetch" in
my query. I posted my unit test here but it seems no one took an interest.
When I get a chance I'll post it to the dev list. My unit test is not as
simple as I'd like it to be. Perhaps you can produce a unit test that is
simpler.

-- 
Daryl Stultz
_
6 Degrees Software and Consulting, Inc.
http://www.6degrees.com
mailto:da...@6degrees.com


Re: Out of bounds exception with fetch plan

2009-12-04 Thread Srinivasan Krishnamoorthy

Hi Daryl,
 Did you get a solution to this problem... We are also facing exactly the
same issue.. 

My query is something like.. 

"select DISTINCT o from Organisation o where o.typeFlag=0 and o.name like
:name".

The entity Organisation shares many OneToMany relations with other entities.
(some are self-referencing).
Am not able to figure out whats the problem..

I get the below exception trace.. 

Caused by: java.lang.ArrayIndexOutOfBoundsException: Array index out of
range: 3
at
org.apache.openjpa.meta.ClassMetaData.getExtraFieldDataIndex(ClassMetaData.java:860)
at
org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initializeState(JDBCStoreManager.java:358)
at
org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initialize(JDBCStoreManager.java:278)
at
com.ibm.ws.persistence.jdbc.kernel.WsJpaJDBCStoreManager.initialize(WsJpaJDBCStoreManager.java:144)
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:894)
at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:852)

I am using DB2 v 9.1.

Best Regards,
Srinivasan Krishnamoorthy.



Daryl Stultz wrote:
> 
> Hello, I'm getting the following:
> 
> java.lang.ArrayIndexOutOfBoundsException: 2
> at
> org.apache.openjpa.meta.ClassMetaData.getExtraFieldDataIndex(ClassMetaData.java:859)
> at
> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initializeState(JDBCStoreManager.java:358)
> at
> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initialize(JDBCStoreManager.java:278)
> 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:894)
> at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:852)
> at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:774)
> at
> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:982)
> at
> org.apache.openjpa.jdbc.sql.AbstractResult.load(AbstractResult.java:278)
> at
> org.apache.openjpa.jdbc.sql.SelectImpl$SelectResult.load(SelectImpl.java:2400)
> at
> org.apache.openjpa.jdbc.meta.strats.RelationFieldStrategy.loadEagerJoin(RelationFieldStrategy.java:541)
> at
> org.apache.openjpa.jdbc.meta.FieldMapping.loadEagerJoin(FieldMapping.java:807)--
> 
> 
> I've attached a unit test that exposes it. I've done my best to pare
> things
> down but it seems anything else I remove makes it go away (there are
> several
> things that could be removed to make it go away). The unit test passes
> when
> the exception is thrown.
> 
> In short, this works:
> 
> Query query = em.createQuery("select o from Case as o" +
> " left join fetch o.scheduledAssignments" +
> " where o.scheduleDay = :sd");
> query.setParameter("sd", sd);
> List allCases = query.getResultList();
> 
> But this doesn't:
> 
> Query query = em.createQuery("select o from Case as o" +
> " where o.scheduleDay = :sd");
> query.setParameter("sd", sd);
> FetchPlan fetchPlan = ((QueryImpl) query).getFetchPlan();
> fetchPlan.addField(Case.class, "scheduledAssignments");
> List allCases = query.getResultList();
> 
> The test case runs against PostgreSQL. I would really appreciate it if
> someone could verify the test passes under some other database or if it
> fails, under PostgreSQL. Of course it would be even better if an OpenJPA
> expert could find the problem.
> 
> I will also accept suggestions for building a better unit test package.
> 
> Thanks for your help.
> 
> Daryl Stultz
> _
> 6 Degrees Software and Consulting, Inc.
> http://www.6degrees.com
> mailto:da...@6degrees.com
> 
>  
> 

-- 
View this message in context: 
http://n2.nabble.com/Out-of-bounds-exception-with-fetch-plan-tp4028405p4111206.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.


Re: Out of bounds exception with fetch plan

2009-12-04 Thread Srinivasan Krishnamoorthy

Hi Daryl,
 Did you get a solution to this problem... We are also facing exactly the
same issue.. 

My query is something like.. 

"select DISTINCT o from Organisation o where o.typeFlag=0 and o.name like
:name".

The entity Organisation shares many OneToMany relations with other entities.
(some are self-referencing).
Am not able to figure out whats the problem..

I get the below exception trace.. 

Caused by: java.lang.ArrayIndexOutOfBoundsException: Array index out of
range: 3
at
org.apache.openjpa.meta.ClassMetaData.getExtraFieldDataIndex(ClassMetaData.java:860)
at
org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initializeState(JDBCStoreManager.java:358)
at
org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initialize(JDBCStoreManager.java:278)
at
com.ibm.ws.persistence.jdbc.kernel.WsJpaJDBCStoreManager.initialize(WsJpaJDBCStoreManager.java:144)
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:894)
at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:852)

I am using DB2 v 9.1.

Best Regards,
Srinivasan Krishnamoorthy.



Daryl Stultz wrote:
> 
> Hello, I'm getting the following:
> 
> java.lang.ArrayIndexOutOfBoundsException: 2
> at
> org.apache.openjpa.meta.ClassMetaData.getExtraFieldDataIndex(ClassMetaData.java:859)
> at
> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initializeState(JDBCStoreManager.java:358)
> at
> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initialize(JDBCStoreManager.java:278)
> 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:894)
> at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:852)
> at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:774)
> at
> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:982)
> at
> org.apache.openjpa.jdbc.sql.AbstractResult.load(AbstractResult.java:278)
> at
> org.apache.openjpa.jdbc.sql.SelectImpl$SelectResult.load(SelectImpl.java:2400)
> at
> org.apache.openjpa.jdbc.meta.strats.RelationFieldStrategy.loadEagerJoin(RelationFieldStrategy.java:541)
> at
> org.apache.openjpa.jdbc.meta.FieldMapping.loadEagerJoin(FieldMapping.java:807)--
> 
> 
> I've attached a unit test that exposes it. I've done my best to pare
> things
> down but it seems anything else I remove makes it go away (there are
> several
> things that could be removed to make it go away). The unit test passes
> when
> the exception is thrown.
> 
> In short, this works:
> 
> Query query = em.createQuery("select o from Case as o" +
> " left join fetch o.scheduledAssignments" +
> " where o.scheduleDay = :sd");
> query.setParameter("sd", sd);
> List allCases = query.getResultList();
> 
> But this doesn't:
> 
> Query query = em.createQuery("select o from Case as o" +
> " where o.scheduleDay = :sd");
> query.setParameter("sd", sd);
> FetchPlan fetchPlan = ((QueryImpl) query).getFetchPlan();
> fetchPlan.addField(Case.class, "scheduledAssignments");
> List allCases = query.getResultList();
> 
> The test case runs against PostgreSQL. I would really appreciate it if
> someone could verify the test passes under some other database or if it
> fails, under PostgreSQL. Of course it would be even better if an OpenJPA
> expert could find the problem.
> 
> I will also accept suggestions for building a better unit test package.
> 
> Thanks for your help.
> 
> Daryl Stultz
> _
> 6 Degrees Software and Consulting, Inc.
> http://www.6degrees.com
> mailto:da...@6degrees.com
> 
>  
> 

-- 
View this message in context: 
http://n2.nabble.com/Out-of-bounds-exception-with-fetch-plan-tp4028405p4111204.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.