You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by Dain Sundstrom <da...@iq80.com> on 2007/08/10 01:42:45 UTC
Unenhanced Classes
I just discovered the new Unehanced Class support, and am super
excited. I was one of the grumblers Craig mentioned :)
I've read the archives, but have a few questions. I apologize if
this was covered somewhere else.
In Java5 without an agent and enhancement, what doesn't work
perfectly (I don't care about performance issues)?
Does the Java6 redefine code work?
In OpenEJB we don't use the OpenJPA agent (we have our own). What
do we have to do to get Java6 redefine working with OpenJPA?
Thanks,
-dain
Re: Unenhanced Classes
Posted by Dain Sundstrom <da...@iq80.com>.
On Aug 13, 2007, at 5:23 PM, Dain Sundstrom wrote:
> On Aug 10, 2007, at 3:44 PM, Patrick Linskey wrote:
>
> Unenhanced, complex primary keys throw an exception when calling
> em.persist(myObject), but only if the id fields are in a
> MappedSuperclass.
This is OPENJPA-314
It should be very easy to fix. Looks like a book keeping problem in
ClassMetaData. I tried to fix it myself, but I got lost in all the
fields and what is supposed to be in them.
-dain
Re: Unenhanced Classes
Posted by Dain Sundstrom <da...@iq80.com>.
On Aug 10, 2007, at 3:44 PM, Patrick Linskey wrote:
>> Anyway, any ideas on a work around for these problems or is this
>> something I can help with?
>
> Failing tests would be swell -- just make the test name be 'xtestFoo'
> or something so that we don't pick it up.
>
> The permanent lazy loading problem is that without redefinition, with
> all field access instances, and with field or prop access with
> user-created instances, automatic lazy loading for single-valued
> fields is unavailable, since we cannot receive notification of when to
> do the lazy load. I believe that we have code in place to ignore the
> lazy directive in these situations, but that could be broken /
> unimplemented.
After about 2 days of painful hacking I finally have a test case that
reproduce this problem. It is very difficult to get unenhanced an
enhanced in the same test. The test is in OpenEJB at
org.apache.openejb.core.cmp.jpa.UnenhancedTest for now, but tomorrow
I'll try to integrate them into OpenJPA.
In the mean time, here is what I found out about the failures:
Unenhanced, complex primary keys throw an exception when calling
em.persist(myObject), but only if the id fields are in a
MappedSuperclass.
Unenhanced, auto generated id's are not filled in after a persist
with flush. Strangely, a String auto generated pk seems to work
file, but a long throws an exception.
Unenhanced, OneToMany (collection valued relationship) are null when
loaded from the database.
Anyway, with some luck, I'll be able to port over the classes tomorrow.
-dain
Re: Unenhanced Classes
Posted by Patrick Linskey <pl...@gmail.com>.
Hi,
What's your environment? Are you using Java 5 or 6? Are you using an
agent? If in 5 and you have your own agent, it'd definitely be better
if you could make a call to our agent to get things set up.
> Anyway, any ideas on a work around for these problems or is this
> something I can help with?
Failing tests would be swell -- just make the test name be 'xtestFoo'
or something so that we don't pick it up.
The permanent lazy loading problem is that without redefinition, with
all field access instances, and with field or prop access with
user-created instances, automatic lazy loading for single-valued
fields is unavailable, since we cannot receive notification of when to
do the lazy load. I believe that we have code in place to ignore the
lazy directive in these situations, but that could be broken /
unimplemented.
-Patrick
On 8/10/07, Dain Sundstrom <da...@iq80.com> wrote:
> This feature is almost working perfectly for me. I am seeing 3
> errors repeated though out my test cases.
>
> 1 ==================
>
> The first exception happens when I have a complex primary key.
>
> <1.0.0-SNAPSHOT-SNAPSHOT nonfatal general error>
> org.apache.openjpa.persistence.PersistenceException: null
> at org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2437)
> at org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2251)
> at org.apache.openjpa.kernel.DelegatingBroker.persist
> (DelegatingBroker.java:1010)
> at org.apache.openjpa.persistence.EntityManagerImpl.persist
> (EntityManagerImpl.java:541)
> at org.apache.openejb.persistence.JtaEntityManager.persist
> (JtaEntityManager.java:97)
> at org.apache.openejb.core.cmp.jpa.JpaCmpEngine.createBean
> (JpaCmpEngine.java:142)
> at org.apache.openejb.core.cmp.CmpContainer.createEJBObject
> (CmpContainer.java:642)
> ......
> Caused by: java.lang.NullPointerException
> at org.apache.openjpa.util.ApplicationIds
> $PrimaryKeyFieldManager.retrieve(ApplicationIds.java:555)
> at org.apache.openjpa.util.ApplicationIds
> $PrimaryKeyFieldManager.fetchStringField(ApplicationIds.java:540)
> at org.apache.openjpa.enhance.openejb$org$apache$openejb$test$entity
> $cmp$ComplexCmpBeanX$pcsubclass.pcCopyKeyFieldsToObjectId(Unknown
> Source)
> at org.apache.openjpa.enhance.PCRegistry.copyKeyFieldsToObjectId
> (PCRegistry.java:160)
> at org.apache.openjpa.util.ApplicationIds.fromPKValues
> (ApplicationIds.java:182)
> at
> org.apache.openjpa.enhance.ReflectingPersistenceCapable.pcNewObjectIdIns
> tance(ReflectingPersistenceCapable.java:257)
> at org.apache.openjpa.util.ApplicationIds.create(ApplicationIds.java:
> 381)
> at org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2405)
> ... 30 more
>
> This is an CMP primary key so the fields are public:
>
> public class ComplexCmpBeanPk implements Serializable {
> public String firstName;
> public String lastName;
> ...
> }
>
> And the bean is a CMP 1.1 class so the fields are public also (yes I
> know this is bad practice but it is how the CMP specs worked).
>
> 2 ==================
>
> The second exception occurs with auto generated primary keys:
>
> <1.0.0-SNAPSHOT-SNAPSHOT nonfatal general error>
> org.apache.openjpa.persistence.PersistenceException: null
> at org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2437)
> at org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2251)
> at org.apache.openjpa.kernel.DelegatingBroker.persist
> (DelegatingBroker.java:1010)
> at org.apache.openjpa.persistence.EntityManagerImpl.persist
> (EntityManagerImpl.java:541)
> at org.apache.openejb.persistence.JtaEntityManager.persist
> (JtaEntityManager.java:97)
> at org.apache.openejb.core.cmp.jpa.JpaCmpEngine.createBean
> (JpaCmpEngine.java:142)
> at org.apache.openejb.core.cmp.CmpContainer.createEJBObject
> (CmpContainer.java:642)
> ......
> Caused by: java.lang.NullPointerException
> at org.apache.openjpa.util.ApplicationIds.fromPKValues
> (ApplicationIds.java:155)
> at
> org.apache.openjpa.enhance.ReflectingPersistenceCapable.pcNewObjectIdIns
> tance(ReflectingPersistenceCapable.java:257)
> at org.apache.openjpa.util.ApplicationIds.create(ApplicationIds.java:
> 381)
> at org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2405)
> ... 30 more
>
> 3 ==================
>
> The final problem is that it appears that collection valued
> relationship fields are always null. I always access the JPA beans
> from within a transaction, so this isn't a disconnected problem. Is
> this the lazy load problem you mentioned below?
>
> ==================
>
>
> Anyway, any ideas on a work around for these problems or is this
> something I can help with?
>
> -dain
>
>
> On Aug 9, 2007, at 8:05 PM, Dain Sundstrom wrote:
>
> > On Aug 9, 2007, at 6:26 PM, Patrick Linskey wrote:
> >
> >> Hi,
> >>
> >> Some brief notes:
> >>
> >>> In Java5 without an agent and enhancement, what doesn't work
> >>> perfectly (I don't care about performance issues)?
> >>
> >> - Lazy loading on user-created instances after flush
> >
> > What is this and is this something the user would notice? Also, is
> > this something that can be fixed or is this just the way it works?
> >
> >> - generated value field / property access will not materialize the
> >> generated value automatically
> >
> > Can I force the generated value to materialize somehow, and as
> > above is this something that we can fix?
> >
> >>> Does the Java6 redefine code work?
> >>
> >> Yes, in at least Sun's Java 6 configurations.
> >
> > Super cool! I can't wait to read that code over.
> >
> >>> In OpenEJB we don't use the OpenJPA agent (we have our own).
> >>> What
> >>> do we have to do to get Java6 redefine working with OpenJPA?
> >>
> >> Nothing. But if you've got your own agent and you know the list of
> >> persistent types up-front, you might want to consider doing automatic
> >> runtime enhancement instead of automatic runtime redefinition.
> >
> > We do, but there are some embedded cases where a class can be
> > loaded before we are even launched. So how do you get ahold of the
> > Instrumentation instance (so you can call redefine) if your agent
> > isn't loaded?
> >
> > -dain
>
>
--
Patrick Linskey
202 669 5907
Re: Unenhanced Classes
Posted by Dain Sundstrom <da...@iq80.com>.
This feature is almost working perfectly for me. I am seeing 3
errors repeated though out my test cases.
1 ==================
The first exception happens when I have a complex primary key.
<1.0.0-SNAPSHOT-SNAPSHOT nonfatal general error>
org.apache.openjpa.persistence.PersistenceException: null
at org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2437)
at org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2251)
at org.apache.openjpa.kernel.DelegatingBroker.persist
(DelegatingBroker.java:1010)
at org.apache.openjpa.persistence.EntityManagerImpl.persist
(EntityManagerImpl.java:541)
at org.apache.openejb.persistence.JtaEntityManager.persist
(JtaEntityManager.java:97)
at org.apache.openejb.core.cmp.jpa.JpaCmpEngine.createBean
(JpaCmpEngine.java:142)
at org.apache.openejb.core.cmp.CmpContainer.createEJBObject
(CmpContainer.java:642)
......
Caused by: java.lang.NullPointerException
at org.apache.openjpa.util.ApplicationIds
$PrimaryKeyFieldManager.retrieve(ApplicationIds.java:555)
at org.apache.openjpa.util.ApplicationIds
$PrimaryKeyFieldManager.fetchStringField(ApplicationIds.java:540)
at org.apache.openjpa.enhance.openejb$org$apache$openejb$test$entity
$cmp$ComplexCmpBeanX$pcsubclass.pcCopyKeyFieldsToObjectId(Unknown
Source)
at org.apache.openjpa.enhance.PCRegistry.copyKeyFieldsToObjectId
(PCRegistry.java:160)
at org.apache.openjpa.util.ApplicationIds.fromPKValues
(ApplicationIds.java:182)
at
org.apache.openjpa.enhance.ReflectingPersistenceCapable.pcNewObjectIdIns
tance(ReflectingPersistenceCapable.java:257)
at org.apache.openjpa.util.ApplicationIds.create(ApplicationIds.java:
381)
at org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2405)
... 30 more
This is an CMP primary key so the fields are public:
public class ComplexCmpBeanPk implements Serializable {
public String firstName;
public String lastName;
...
}
And the bean is a CMP 1.1 class so the fields are public also (yes I
know this is bad practice but it is how the CMP specs worked).
2 ==================
The second exception occurs with auto generated primary keys:
<1.0.0-SNAPSHOT-SNAPSHOT nonfatal general error>
org.apache.openjpa.persistence.PersistenceException: null
at org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2437)
at org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2251)
at org.apache.openjpa.kernel.DelegatingBroker.persist
(DelegatingBroker.java:1010)
at org.apache.openjpa.persistence.EntityManagerImpl.persist
(EntityManagerImpl.java:541)
at org.apache.openejb.persistence.JtaEntityManager.persist
(JtaEntityManager.java:97)
at org.apache.openejb.core.cmp.jpa.JpaCmpEngine.createBean
(JpaCmpEngine.java:142)
at org.apache.openejb.core.cmp.CmpContainer.createEJBObject
(CmpContainer.java:642)
......
Caused by: java.lang.NullPointerException
at org.apache.openjpa.util.ApplicationIds.fromPKValues
(ApplicationIds.java:155)
at
org.apache.openjpa.enhance.ReflectingPersistenceCapable.pcNewObjectIdIns
tance(ReflectingPersistenceCapable.java:257)
at org.apache.openjpa.util.ApplicationIds.create(ApplicationIds.java:
381)
at org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2405)
... 30 more
3 ==================
The final problem is that it appears that collection valued
relationship fields are always null. I always access the JPA beans
from within a transaction, so this isn't a disconnected problem. Is
this the lazy load problem you mentioned below?
==================
Anyway, any ideas on a work around for these problems or is this
something I can help with?
-dain
On Aug 9, 2007, at 8:05 PM, Dain Sundstrom wrote:
> On Aug 9, 2007, at 6:26 PM, Patrick Linskey wrote:
>
>> Hi,
>>
>> Some brief notes:
>>
>>> In Java5 without an agent and enhancement, what doesn't work
>>> perfectly (I don't care about performance issues)?
>>
>> - Lazy loading on user-created instances after flush
>
> What is this and is this something the user would notice? Also, is
> this something that can be fixed or is this just the way it works?
>
>> - generated value field / property access will not materialize the
>> generated value automatically
>
> Can I force the generated value to materialize somehow, and as
> above is this something that we can fix?
>
>>> Does the Java6 redefine code work?
>>
>> Yes, in at least Sun's Java 6 configurations.
>
> Super cool! I can't wait to read that code over.
>
>>> In OpenEJB we don't use the OpenJPA agent (we have our own).
>>> What
>>> do we have to do to get Java6 redefine working with OpenJPA?
>>
>> Nothing. But if you've got your own agent and you know the list of
>> persistent types up-front, you might want to consider doing automatic
>> runtime enhancement instead of automatic runtime redefinition.
>
> We do, but there are some embedded cases where a class can be
> loaded before we are even launched. So how do you get ahold of the
> Instrumentation instance (so you can call redefine) if your agent
> isn't loaded?
>
> -dain
Re: Unenhanced Classes
Posted by Dain Sundstrom <da...@iq80.com>.
On Aug 9, 2007, at 6:26 PM, Patrick Linskey wrote:
> Hi,
>
> Some brief notes:
>
>> In Java5 without an agent and enhancement, what doesn't work
>> perfectly (I don't care about performance issues)?
>
> - Lazy loading on user-created instances after flush
What is this and is this something the user would notice? Also, is
this something that can be fixed or is this just the way it works?
> - generated value field / property access will not materialize the
> generated value automatically
Can I force the generated value to materialize somehow, and as above
is this something that we can fix?
>> Does the Java6 redefine code work?
>
> Yes, in at least Sun's Java 6 configurations.
Super cool! I can't wait to read that code over.
>> In OpenEJB we don't use the OpenJPA agent (we have our own). What
>> do we have to do to get Java6 redefine working with OpenJPA?
>
> Nothing. But if you've got your own agent and you know the list of
> persistent types up-front, you might want to consider doing automatic
> runtime enhancement instead of automatic runtime redefinition.
We do, but there are some embedded cases where a class can be loaded
before we are even launched. So how do you get ahold of the
Instrumentation instance (so you can call redefine) if your agent
isn't loaded?
-dain
Re: Unenhanced Classes
Posted by Patrick Linskey <pl...@gmail.com>.
Hi,
Some brief notes:
> In Java5 without an agent and enhancement, what doesn't work
> perfectly (I don't care about performance issues)?
- Lazy loading on user-created instances after flush
- generated value field / property access will not materialize the
generated value automatically
> Does the Java6 redefine code work?
Yes, in at least Sun's Java 6 configurations.
> In OpenEJB we don't use the OpenJPA agent (we have our own). What
> do we have to do to get Java6 redefine working with OpenJPA?
Nothing. But if you've got your own agent and you know the list of
persistent types up-front, you might want to consider doing automatic
runtime enhancement instead of automatic runtime redefinition.
-Patrick
On 8/9/07, Dain Sundstrom <da...@iq80.com> wrote:
> I just discovered the new Unehanced Class support, and am super
> excited. I was one of the grumblers Craig mentioned :)
>
> I've read the archives, but have a few questions. I apologize if
> this was covered somewhere else.
>
> In Java5 without an agent and enhancement, what doesn't work
> perfectly (I don't care about performance issues)?
>
> Does the Java6 redefine code work?
>
> In OpenEJB we don't use the OpenJPA agent (we have our own). What
> do we have to do to get Java6 redefine working with OpenJPA?
>
>
> Thanks,
>
> -dain
>
>
>
>
>
>
--
Patrick Linskey
202 669 5907