You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Adam Hardy <ad...@cyberspaceroad.org> on 2008/04/08 14:16:45 UTC
Re: exception from merging
I have reduced this to a stand-alone unit test and also tested it against
Toplink and Hibernate, with which it works.
So I'm looking at a pure OpenJPA issue here.
Here is the low-down:
- Parent - child entities mapped using XML as opposed to annotations
- both inherit a mapped superclass
- both have a prepersist and preupdate listener configured
- not using enhancement
This is all I do:
EntityManager entityManager =
db.entityManagerFactory.createEntityManager();
entityManager.getTransaction().begin();
Genus genus = entityManager.find(Genus.class, new Long(1));
entityManager.getTransaction().commit();
entityManager.close();
// now detached
entityManager = db.entityManagerFactory.createEntityManager();
entityManager.getTransaction().begin();
entityManager.merge(genus);
and it throws an exception. If there is a child row in the db, I get the
exception below.
If there is no child in existence, I get a NullPointerException.
If I enhance the entities, all is hunkydory.
This is using OpenJPA v1.1.0 snapshot from February.
Do you want a bug report filed?
Regards
Adam
Adam Hardy on 07/04/08 16:27, wrote:
>
> I called merge on my parent entity because it is detached.
>
> You can see from the stacktrace that something in merge() is not happening.
>
> $Proxy13 seems to be the name of the parent's child collection property,
> I can see from debugging.
>
> Does anybody recognise the problem?
>
>
> <openjpa-1.1.0-SNAPSHOT-r420667:609825 fatal general error>
> org.apache.openjpa.persistence.PersistenceException: Unable to create a
> second class object proxy for final class "class $Proxy13".
> at
> org.apache.openjpa.util.ProxyManagerImpl.assertNotFinal(ProxyManagerImpl.java:555)
>
> at
> org.apache.openjpa.util.ProxyManagerImpl.generateProxyCollectionBytecode(ProxyManagerImpl.java:524)
>
> at
> org.apache.openjpa.util.ProxyManagerImpl.getFactoryProxyCollection(ProxyManagerImpl.java:373)
>
> at
> org.apache.openjpa.util.ProxyManagerImpl.copyCollection(ProxyManagerImpl.java:192)
>
> at
> org.apache.openjpa.kernel.AttachStrategy.copyCollection(AttachStrategy.java:342)
>
> at
> org.apache.openjpa.kernel.AttachStrategy.attachCollection(AttachStrategy.java:319)
>
> at
> org.apache.openjpa.kernel.AttachStrategy.replaceList(AttachStrategy.java:357)
>
> at
> org.apache.openjpa.kernel.AttachStrategy.attachField(AttachStrategy.java:222)
>
> at
> org.apache.openjpa.kernel.VersionAttachStrategy.attach(VersionAttachStrategy.java:151)
>
> at
> org.apache.openjpa.kernel.AttachManager.attach(AttachManager.java:241)
> at
> org.apache.openjpa.kernel.AttachManager.attach(AttachManager.java:101)
> at org.apache.openjpa.kernel.BrokerImpl.attach(BrokerImpl.java:3196)
> at
> org.apache.openjpa.kernel.DelegatingBroker.attach(DelegatingBroker.java:1142)
>
> at
> org.apache.openjpa.persistence.EntityManagerImpl.merge(EntityManagerImpl.java:736)
>
> at
> org.permacode.atomictest.jpa.JpaSpeciesDao.persist(JpaSpeciesDao.java:81)
>
>
Re: exception from merging
Posted by Adam Hardy <ad...@cyberspaceroad.org>.
OK, here it is:
https://issues.apache.org/jira/browse/OPENJPA-560
Hopefully that makes it plain where and when it is happening.
regards
Adam
Michael Dick on 08/04/08 16:17, wrote:
> Hi Adam,
>
> Please do open a JIRA. If you wouldn't mind including a testcase that
> demonstrates the problem that would be much appreciated too.
>
> -Mike
>
> On Tue, Apr 8, 2008 at 7:16 AM, Adam Hardy <ad...@cyberspaceroad.org>
> wrote:
>
>> I have reduced this to a stand-alone unit test and also tested it against
>> Toplink and Hibernate, with which it works.
>>
>> So I'm looking at a pure OpenJPA issue here.
>>
>> Here is the low-down:
>>
>> - Parent - child entities mapped using XML as opposed to annotations
>> - both inherit a mapped superclass
>> - both have a prepersist and preupdate listener configured
>> - not using enhancement
>>
>> This is all I do:
>>
>> EntityManager entityManager =
>> db.entityManagerFactory.createEntityManager();
>> entityManager.getTransaction().begin();
>> Genus genus = entityManager.find(Genus.class, new Long(1));
>> entityManager.getTransaction().commit();
>> entityManager.close();
>> // now detached
>> entityManager = db.entityManagerFactory.createEntityManager();
>> entityManager.getTransaction().begin();
>> entityManager.merge(genus);
>>
>> and it throws an exception. If there is a child row in the db, I get the
>> exception below.
>>
>> If there is no child in existence, I get a NullPointerException.
>>
>> If I enhance the entities, all is hunkydory.
>>
>> This is using OpenJPA v1.1.0 snapshot from February.
>>
>> Do you want a bug report filed?
>>
>> Regards Adam
>>
>>
>>
>>
>> Adam Hardy on 07/04/08 16:27, wrote:
>>
>>> I called merge on my parent entity because it is detached.
>>>
>>> You can see from the stacktrace that something in merge() is not
>>> happening.
>>>
>>> $Proxy13 seems to be the name of the parent's child collection property,
>>> I can see from debugging.
>>>
>>> Does anybody recognise the problem?
>>>
>>>
>>> <openjpa-1.1.0-SNAPSHOT-r420667:609825 fatal general error>
>>> org.apache.openjpa.persistence.PersistenceException: Unable to create a
>>> second class object proxy for final class "class $Proxy13". at
>>> org.apache.openjpa.util.ProxyManagerImpl.assertNotFinal(ProxyManagerImpl.java:555)
>>>
>>>
>>> at
>>> org.apache.openjpa.util.ProxyManagerImpl.generateProxyCollectionBytecode(ProxyManagerImpl.java:524)
>>>
>>>
>>> at
>>> org.apache.openjpa.util.ProxyManagerImpl.getFactoryProxyCollection(ProxyManagerImpl.java:373)
>>>
>>>
>>> at
>>> org.apache.openjpa.util.ProxyManagerImpl.copyCollection(ProxyManagerImpl.java:192)
>>>
>>>
>>> at
>>> org.apache.openjpa.kernel.AttachStrategy.copyCollection(AttachStrategy.java:342)
>>>
>>>
>>> at
>>> org.apache.openjpa.kernel.AttachStrategy.attachCollection(AttachStrategy.java:319)
>>>
>>>
>>> at
>>> org.apache.openjpa.kernel.AttachStrategy.replaceList(AttachStrategy.java:357)
>>>
>>>
>>> at
>>> org.apache.openjpa.kernel.AttachStrategy.attachField(AttachStrategy.java:222)
>>>
>>>
>>> at
>>> org.apache.openjpa.kernel.VersionAttachStrategy.attach(VersionAttachStrategy.java:151)
>>>
>>>
>>> at org.apache.openjpa.kernel.AttachManager.attach(AttachManager.java:241)
>>> at
>>> org.apache.openjpa.kernel.AttachManager.attach(AttachManager.java:101) at
>>> org.apache.openjpa.kernel.BrokerImpl.attach(BrokerImpl.java:3196) at
>>> org.apache.openjpa.kernel.DelegatingBroker.attach(DelegatingBroker.java:1142)
>>>
>>>
>>> at
>>> org.apache.openjpa.persistence.EntityManagerImpl.merge(EntityManagerImpl.java:736)
>>>
>>>
>>> at
>>> org.permacode.atomictest.jpa.JpaSpeciesDao.persist(JpaSpeciesDao.java:81)
>>>
>>>
>>>
>>>
>
Re: exception from merging
Posted by Michael Dick <mi...@gmail.com>.
Hi Adam,
Please do open a JIRA. If you wouldn't mind including a testcase that
demonstrates the problem that would be much appreciated too.
-Mike
On Tue, Apr 8, 2008 at 7:16 AM, Adam Hardy <ad...@cyberspaceroad.org>
wrote:
> I have reduced this to a stand-alone unit test and also tested it against
> Toplink and Hibernate, with which it works.
>
> So I'm looking at a pure OpenJPA issue here.
>
> Here is the low-down:
>
> - Parent - child entities mapped using XML as opposed to annotations
> - both inherit a mapped superclass
> - both have a prepersist and preupdate listener configured
> - not using enhancement
>
> This is all I do:
>
> EntityManager entityManager =
> db.entityManagerFactory.createEntityManager();
> entityManager.getTransaction().begin();
> Genus genus = entityManager.find(Genus.class, new Long(1));
> entityManager.getTransaction().commit();
> entityManager.close();
> // now detached
> entityManager = db.entityManagerFactory.createEntityManager();
> entityManager.getTransaction().begin();
> entityManager.merge(genus);
>
> and it throws an exception. If there is a child row in the db, I get the
> exception below.
>
> If there is no child in existence, I get a NullPointerException.
>
> If I enhance the entities, all is hunkydory.
>
> This is using OpenJPA v1.1.0 snapshot from February.
>
> Do you want a bug report filed?
>
> Regards
> Adam
>
>
>
>
> Adam Hardy on 07/04/08 16:27, wrote:
>
> >
> > I called merge on my parent entity because it is detached.
> >
> > You can see from the stacktrace that something in merge() is not
> > happening.
> >
> > $Proxy13 seems to be the name of the parent's child collection property,
> > I can see from debugging.
> >
> > Does anybody recognise the problem?
> >
> >
> > <openjpa-1.1.0-SNAPSHOT-r420667:609825 fatal general error>
> > org.apache.openjpa.persistence.PersistenceException: Unable to create a
> > second class object proxy for final class "class $Proxy13".
> > at
> > org.apache.openjpa.util.ProxyManagerImpl.assertNotFinal(ProxyManagerImpl.java:555)
> >
> > at
> > org.apache.openjpa.util.ProxyManagerImpl.generateProxyCollectionBytecode(ProxyManagerImpl.java:524)
> >
> > at
> > org.apache.openjpa.util.ProxyManagerImpl.getFactoryProxyCollection(ProxyManagerImpl.java:373)
> >
> > at
> > org.apache.openjpa.util.ProxyManagerImpl.copyCollection(ProxyManagerImpl.java:192)
> >
> > at
> > org.apache.openjpa.kernel.AttachStrategy.copyCollection(AttachStrategy.java:342)
> >
> > at
> > org.apache.openjpa.kernel.AttachStrategy.attachCollection(AttachStrategy.java:319)
> >
> > at
> > org.apache.openjpa.kernel.AttachStrategy.replaceList(AttachStrategy.java:357)
> >
> > at
> > org.apache.openjpa.kernel.AttachStrategy.attachField(AttachStrategy.java:222)
> >
> > at
> > org.apache.openjpa.kernel.VersionAttachStrategy.attach(VersionAttachStrategy.java:151)
> >
> > at
> > org.apache.openjpa.kernel.AttachManager.attach(AttachManager.java:241)
> > at
> > org.apache.openjpa.kernel.AttachManager.attach(AttachManager.java:101)
> > at org.apache.openjpa.kernel.BrokerImpl.attach(BrokerImpl.java:3196)
> > at
> > org.apache.openjpa.kernel.DelegatingBroker.attach(DelegatingBroker.java:1142)
> >
> > at
> > org.apache.openjpa.persistence.EntityManagerImpl.merge(EntityManagerImpl.java:736)
> >
> > at
> > org.permacode.atomictest.jpa.JpaSpeciesDao.persist(JpaSpeciesDao.java:81)
> >
> >
> >
>