You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "Geir Magnusson Jr." <ge...@pobox.com> on 2007/11/15 20:10:10 UTC
@PostPersist woes
Woe is me :)
I'm using @PostPersist to create some kind of machine-generated data
for entities on insert, and I'm running into the following problem
when an entity for which I called persist() has in it a new, unmanaged
entity.
[junit-coverage] Caused by: <openjpa-1.0.0-r420667:568756 fatal user
error> org.apache.openjpa.util.InvalidStateException: Detected
reentrant flush. Make sure your flush-time instance callback methods
or event listeners do not invoke any operations that require the in-
progress flush to complete.
[junit-coverage] at
org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:1840)
[junit-coverage] at
org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:1615)
[junit-coverage] at
org
.apache
.openjpa.kernel.StateManagerImpl.assignObjectId(StateManagerImpl.java:
505)
[junit-coverage] at
org
.apache
.openjpa.kernel.StateManagerImpl.assignField(StateManagerImpl.java:590)
[junit-coverage] at
org
.apache
.openjpa
.kernel.StateManagerImpl.beforeAccessField(StateManagerImpl.java:1451)
[junit-coverage] at
org
.apache
.openjpa.kernel.StateManagerImpl.accessingField(StateManagerImpl.java:
1434)
[junit-coverage] at
com.joost.model.InventoryItem.getId(InventoryItem.java)
[junit-coverage] at
com.joost.model.InventoryItem.initPublicIdIfNull(InventoryItem.java:331)
in InventoryItem, getId is the PK, and my read of the spec says that I
am guaranteed to have it in @PostPersist.
Bug? me doing something wrong?
geir
Re: @PostPersist woes
Posted by "Geir Magnusson Jr." <ge...@pobox.com>.
Here's the full stacktrace :
[junit-coverage] Testcase: testChannelItem took 0.063 sec
[junit-coverage] Caused an ERROR
[junit-coverage] null
[junit-coverage] <openjpa-1.0.0-r420667:568756 fatal user error>
org.apache.openjpa.util.CallbackException: null
[junit-coverage] at
org
.apache
.openjpa.kernel.BrokerImpl.handleCallbackExceptions(BrokerImpl.java:651)
[junit-coverage] at
org
.apache.openjpa.kernel.BrokerImpl.fireLifecycleEvent(BrokerImpl.java:
637)
[junit-coverage] at
org
.apache
.openjpa
.kernel.StateManagerImpl.fireLifecycleEvent(StateManagerImpl.java:333)
[junit-coverage] at
org
.apache
.openjpa.kernel.StateManagerImpl.initialize(StateManagerImpl.java:305)
[junit-coverage] at
org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2391)
[junit-coverage] at
org
.apache
.openjpa.kernel.SingleFieldManager.preFlushPC(SingleFieldManager.java:
760)
[junit-coverage] at
org
.apache
.openjpa.kernel.SingleFieldManager.preFlushPCs(SingleFieldManager.java:
735)
[junit-coverage] at
org
.apache
.openjpa.kernel.SingleFieldManager.preFlush(SingleFieldManager.java:637)
[junit-coverage] at
org
.apache
.openjpa.kernel.SingleFieldManager.preFlush(SingleFieldManager.java:562)
[junit-coverage] at
org
.apache
.openjpa.kernel.SingleFieldManager.preFlush(SingleFieldManager.java:478)
[junit-coverage] at
org
.apache.openjpa.kernel.StateManagerImpl.preFlush(StateManagerImpl.java:
2775)
[junit-coverage] at
org.apache.openjpa.kernel.PNewState.beforeFlush(PNewState.java:39)
[junit-coverage] at
org
.apache
.openjpa.kernel.StateManagerImpl.beforeFlush(StateManagerImpl.java:940)
[junit-coverage] at
org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:1884)
[junit-coverage] at
org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:1844)
[junit-coverage] at
org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:1615)
[junit-coverage] at
org
.apache
.openjpa.kernel.StateManagerImpl.assignObjectId(StateManagerImpl.java:
505)
[junit-coverage] at
org
.apache
.openjpa.kernel.StateManagerImpl.assignField(StateManagerImpl.java:590)
[junit-coverage] at
org
.apache
.openjpa
.kernel.StateManagerImpl.beforeAccessField(StateManagerImpl.java:1451)
[junit-coverage] at
org
.apache
.openjpa.kernel.StateManagerImpl.accessingField(StateManagerImpl.java:
1434)
[junit-coverage] at
com.joost.model.InventoryItem.getId(InventoryItem.java)
[junit-coverage] at
com.joost.model.InventoryItem.initPublicIdIfNull(InventoryItem.java:331)
[junit-coverage] at
org
.apache
.openjpa
.event
.MethodLifecycleCallbacks.makeCallback(MethodLifecycleCallbacks.java:93)
[junit-coverage] at
org
.apache
.openjpa
.event.LifecycleEventManager.makeCallbacks(LifecycleEventManager.java:
322)
[junit-coverage] at
org
.apache
.openjpa
.event.LifecycleEventManager.fireEvent(LifecycleEventManager.java:284)
[junit-coverage] at
org
.apache.openjpa.kernel.BrokerImpl.fireLifecycleEvent(BrokerImpl.java:
637)
[junit-coverage] at
org
.apache
.openjpa
.kernel.StateManagerImpl.fireLifecycleEvent(StateManagerImpl.java:333)
[junit-coverage] at
org
.apache
.openjpa.kernel.StateManagerImpl.initialize(StateManagerImpl.java:305)
[junit-coverage] at
org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2391)
[junit-coverage] at
org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2216)
[junit-coverage] at
org
.apache.openjpa.kernel.DelegatingBroker.persist(DelegatingBroker.java:
1005)
[junit-coverage] at
org
.apache
.openjpa.persistence.EntityManagerImpl.persist(EntityManagerImpl.java:
541)
[junit-coverage] at
org.springframework.orm.jpa.SharedEntityManagerCreator
$
SharedEntityManagerInvocationHandler
.invoke(SharedEntityManagerCreator.java:180)
[junit-coverage] at $Proxy9.persist(Unknown Source)
[junit-coverage] at
com
.joost
.service.impl.AbstractAssetManager.persist(AbstractAssetManager.java:22)
[junit-coverage] at
com.joost.model.ChannelItemT.testChannelItem(ChannelItemT.java:43)
[junit-coverage] at
org
.springframework
.test.ConditionalTestCase.runBare(ConditionalTestCase.java:69)
[junit-coverage] at
junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
[junit-coverage] at junit.extensions.TestSetup
$1.protect(TestSetup.java:21)
[junit-coverage] at junit.extensions.TestSetup.run(TestSetup.java:25)
[junit-coverage] Caused by: java.lang.reflect.InvocationTargetException
[junit-coverage] at
org
.apache
.openjpa
.event
.MethodLifecycleCallbacks.makeCallback(MethodLifecycleCallbacks.java:93)
[junit-coverage] at
org
.apache
.openjpa
.event.LifecycleEventManager.makeCallbacks(LifecycleEventManager.java:
322)
[junit-coverage] at
org
.apache
.openjpa
.event.LifecycleEventManager.fireEvent(LifecycleEventManager.java:284)
[junit-coverage] Caused by: <openjpa-1.0.0-r420667:568756 fatal user
error> org.apache.openjpa.util.InvalidStateException: Detected
reentrant flush. Make sure your flush-time instance callback methods
or event listeners do not invoke any operations that require the in-
progress flush to complete.
[junit-coverage] at
org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:1840)
[junit-coverage] at
org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:1615)
[junit-coverage] at
org
.apache
.openjpa.kernel.StateManagerImpl.assignObjectId(StateManagerImpl.java:
505)
[junit-coverage] at
org
.apache
.openjpa.kernel.StateManagerImpl.assignField(StateManagerImpl.java:590)
[junit-coverage] at
org
.apache
.openjpa
.kernel.StateManagerImpl.beforeAccessField(StateManagerImpl.java:1451)
[junit-coverage] at
org
.apache
.openjpa.kernel.StateManagerImpl.accessingField(StateManagerImpl.java:
1434)
[junit-coverage] at
com.joost.model.InventoryItem.getId(InventoryItem.java)
[junit-coverage] at
com.joost.model.InventoryItem.initPublicIdIfNull(InventoryItem.java:331)
[junit-coverage]
On Nov 15, 2007, at 2:10 PM, Geir Magnusson Jr. wrote:
> Woe is me :)
>
> I'm using @PostPersist to create some kind of machine-generated data
> for entities on insert, and I'm running into the following problem
> when an entity for which I called persist() has in it a new,
> unmanaged entity.
>
> [junit-coverage] Caused by: <openjpa-1.0.0-r420667:568756 fatal user
> error> org.apache.openjpa.util.InvalidStateException: Detected
> reentrant flush. Make sure your flush-time instance callback
> methods or event listeners do not invoke any operations that require
> the in-progress flush to complete.
> [junit-coverage] at
> org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:1840)
> [junit-coverage] at
> org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:1615)
> [junit-coverage] at
> org
> .apache
> .openjpa
> .kernel.StateManagerImpl.assignObjectId(StateManagerImpl.java:505)
> [junit-coverage] at
> org
> .apache
> .openjpa.kernel.StateManagerImpl.assignField(StateManagerImpl.java:
> 590)
> [junit-coverage] at
> org
> .apache
> .openjpa
> .kernel.StateManagerImpl.beforeAccessField(StateManagerImpl.java:1451)
> [junit-coverage] at
> org
> .apache
> .openjpa
> .kernel.StateManagerImpl.accessingField(StateManagerImpl.java:1434)
> [junit-coverage] at
> com.joost.model.InventoryItem.getId(InventoryItem.java)
> [junit-coverage] at
> com.joost.model.InventoryItem.initPublicIdIfNull(InventoryItem.java:
> 331)
>
>
> in InventoryItem, getId is the PK, and my read of the spec says that
> I am guaranteed to have it in @PostPersist.
>
> Bug? me doing something wrong?
>
> geir
>
Re: @PostPersist woes
Posted by "Geir Magnusson Jr." <ge...@pobox.com>.
On Nov 15, 2007, at 4:34 PM, Pinaki Poddar wrote:
>> persist() has in it a new, unmanaged entity.
>
> a) If persist(a) is failing on b, what is the cascade type specified
> on
> relation a.b?
ALL
>
> b) what is the identity definition on b?
IDENTITY
>
> c) if b is using auto-assigned GeneratedValue or its id is being set
> by
> application?
auto-assigned
geir
>
>
> -----Original Message-----
> From: Geir Magnusson Jr. [mailto:geir@pobox.com]
> Sent: Thursday, November 15, 2007 11:10 AM
> To: dev@openjpa.apache.org
> Subject: @PostPersist woes
>
> Woe is me :)
>
> I'm using @PostPersist to create some kind of machine-generated data
> for
> entities on insert, and I'm running into the following problem when an
> entity for which I called persist() has in it a new, unmanaged entity.
>
> [junit-coverage] Caused by: <openjpa-1.0.0-r420667:568756 fatal user
> error> org.apache.openjpa.util.InvalidStateException: Detected
> reentrant flush. Make sure your flush-time instance callback
> methods or
> event listeners do not invoke any operations that require the in-
> progress flush to complete.
> [junit-coverage] at
> org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:1840)
> [junit-coverage] at
> org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:1615)
> [junit-coverage] at
> org
> .apache
> .openjpa.kernel.StateManagerImpl.assignObjectId(StateManagerImpl.java:
> 505)
> [junit-coverage] at
> org
> .apache
> .openjpa.kernel.StateManagerImpl.assignField(StateManagerImpl.java:
> 590)
> [junit-coverage] at
> org
> .apache
> .openjpa
> .kernel.StateManagerImpl.beforeAccessField(StateManagerImpl.java:1451)
> [junit-coverage] at
> org
> .apache
> .openjpa.kernel.StateManagerImpl.accessingField(StateManagerImpl.java:
> 1434)
> [junit-coverage] at
> com.joost.model.InventoryItem.getId(InventoryItem.java)
> [junit-coverage] at
> com.joost.model.InventoryItem.initPublicIdIfNull(InventoryItem.java:
> 331)
>
>
> in InventoryItem, getId is the PK, and my read of the spec says that I
> am guaranteed to have it in @PostPersist.
>
> Bug? me doing something wrong?
>
> geir
>
>
> Notice: This email message, together with any attachments, may
> contain information of BEA Systems, Inc., its subsidiaries and
> affiliated entities, that may be confidential, proprietary,
> copyrighted and/or legally privileged, and is intended solely for
> the use of the individual or entity named in this message. If you
> are not the intended recipient, and have received this message in
> error, please immediately return this by email and then delete it.
RE: @PostPersist woes
Posted by Pinaki Poddar <pp...@bea.com>.
>
>
> If possible, try application set identity for InventoryItem, not the
> provider.
public class X {
@Id
@GeneratedValue
private long id;
// no setId() method;
public class Y {
@Id
private long id;
public void setId(long id) {
this.id = id;
}
}
X is using auto-assigned id, Y is using application id. It is the
responsibility of the application developer to call Y.getId() with
unique values before an instance being persisted. For A, it is the JPA
provider who is responsible for doing the same 'under the hood'.
will wait for your posting of InventoryItem class definition +
@PostPersist code block + the invocation context.
-----Original Message-----
From: Geir Magnusson Jr. [mailto:geir@pobox.com]
Sent: Thursday, November 15, 2007 1:52 PM
To: dev@openjpa.apache.org
Subject: Re: @PostPersist woes
On Nov 15, 2007, at 4:45 PM, Pinaki Poddar wrote:
> It is failing on an instance of InventoryItem.getId() -- is it itself
> the argument of persist() or an instance navigable from it?
This is where things get fun. InventoryItem is a baseclass of A and B
and we're using Joined inheritance strategy. So yes, InventoryItem will
be the arg to persist(). That said, see my next mail where I provide
some detail...
>
>
> If possible, try application set identity for InventoryItem, not the
> provider.
What does that mean? (I'm an openjpa newbie...)
geir
>
>
>
> -----Original Message-----
> From: Geir Magnusson Jr. [mailto:geir@pobox.com]
> Sent: Thursday, November 15, 2007 1:41 PM
> To: dev@openjpa.apache.org
> Subject: Re: @PostPersist woes
>
>
> On Nov 15, 2007, at 4:34 PM, Pinaki Poddar wrote:
>
>>> persist() has in it a new, unmanaged entity.
>>
>> a) If persist(a) is failing on b, what is the cascade type specified
>> on relation a.b?
>
> I'm not actually sure that it's failing on b. I guess I can try to
> figure that out. I just know that when I change things so that I
> have an unmanaged b, it fails.
>
>>
>> b) what is the identity definition on b?
>> c) if b is using auto-assigned GeneratedValue or its id is being set
>> by application?
>>
>> -----Original Message-----
>> From: Geir Magnusson Jr. [mailto:geir@pobox.com]
>> Sent: Thursday, November 15, 2007 11:10 AM
>> To: dev@openjpa.apache.org
>> Subject: @PostPersist woes
>>
>> Woe is me :)
>>
>> I'm using @PostPersist to create some kind of machine-generated data
>> for entities on insert, and I'm running into the following problem
>> when an entity for which I called persist() has in it a new,
>> unmanaged
>
>> entity.
>>
>> [junit-coverage] Caused by: <openjpa-1.0.0-r420667:568756 fatal user
>> error> org.apache.openjpa.util.InvalidStateException: Detected
>> reentrant flush. Make sure your flush-time instance callback methods
>> or event listeners do not invoke any operations that require the in-
>> progress flush to complete.
>> [junit-coverage] at
>> org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:1840)
>> [junit-coverage] at
>> org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:1615)
>> [junit-coverage] at
>> org
>> .apache
>> .openjpa
>> .kernel.StateManagerImpl.assignObjectId(StateManagerImpl.java:
>> 505)
>> [junit-coverage] at
>> org
>> .apache
>> .openjpa.kernel.StateManagerImpl.assignField(StateManagerImpl.java:
>> 590)
>> [junit-coverage] at
>> org
>> .apache
>> .openjpa
>> .kernel.StateManagerImpl.beforeAccessField(StateManagerImpl.java:
>> 1451)
>> [junit-coverage] at
>> org
>> .apache
>> .openjpa
>> .kernel.StateManagerImpl.accessingField(StateManagerImpl.java:
>> 1434)
>> [junit-coverage] at
>> com.joost.model.InventoryItem.getId(InventoryItem.java)
>> [junit-coverage] at
>> com.joost.model.InventoryItem.initPublicIdIfNull(InventoryItem.java:
>> 331)
>>
>>
>> in InventoryItem, getId is the PK, and my read of the spec says that
>> I am guaranteed to have it in @PostPersist.
>>
>> Bug? me doing something wrong?
>>
>> geir
>>
>>
>> Notice: This email message, together with any attachments, may
>> contain information of BEA Systems, Inc., its subsidiaries and
>> affiliated entities, that may be confidential, proprietary,
>> copyrighted and/or legally privileged, and is intended solely for
>> the use of the individual or entity named in this message. If you are
>> not the intended recipient, and have received this message in error,
>> please immediately return this by email and then delete it.
>
>
> Notice: This email message, together with any attachments, may
> contain information of BEA Systems, Inc., its subsidiaries and
> affiliated entities, that may be confidential, proprietary,
> copyrighted and/or legally privileged, and is intended solely for the
> use of the individual or entity named in this message. If you are not
> the intended recipient, and have received this message in error,
> please immediately return this by email and then delete it.
Notice: This email message, together with any attachments, may contain information of BEA Systems, Inc., its subsidiaries and affiliated entities, that may be confidential, proprietary, copyrighted and/or legally privileged, and is intended solely for the use of the individual or entity named in this message. If you are not the intended recipient, and have received this message in error, please immediately return this by email and then delete it.
Re: @PostPersist woes
Posted by "Geir Magnusson Jr." <ge...@pobox.com>.
On Nov 15, 2007, at 4:45 PM, Pinaki Poddar wrote:
> It is failing on an instance of InventoryItem.getId() -- is it itself
> the argument of persist() or an instance navigable from it?
This is where things get fun. InventoryItem is a baseclass of A and B
and we're using Joined inheritance strategy. So yes, InventoryItem
will be the arg to persist(). That said, see my next mail where I
provide some detail...
>
>
> If possible, try application set identity for InventoryItem, not the
> provider.
What does that mean? (I'm an openjpa newbie...)
geir
>
>
>
> -----Original Message-----
> From: Geir Magnusson Jr. [mailto:geir@pobox.com]
> Sent: Thursday, November 15, 2007 1:41 PM
> To: dev@openjpa.apache.org
> Subject: Re: @PostPersist woes
>
>
> On Nov 15, 2007, at 4:34 PM, Pinaki Poddar wrote:
>
>>> persist() has in it a new, unmanaged entity.
>>
>> a) If persist(a) is failing on b, what is the cascade type specified
>> on relation a.b?
>
> I'm not actually sure that it's failing on b. I guess I can try to
> figure that out. I just know that when I change things so that I
> have
> an unmanaged b, it fails.
>
>>
>> b) what is the identity definition on b?
>> c) if b is using auto-assigned GeneratedValue or its id is being set
>> by application?
>>
>> -----Original Message-----
>> From: Geir Magnusson Jr. [mailto:geir@pobox.com]
>> Sent: Thursday, November 15, 2007 11:10 AM
>> To: dev@openjpa.apache.org
>> Subject: @PostPersist woes
>>
>> Woe is me :)
>>
>> I'm using @PostPersist to create some kind of machine-generated data
>> for entities on insert, and I'm running into the following problem
>> when an entity for which I called persist() has in it a new,
>> unmanaged
>
>> entity.
>>
>> [junit-coverage] Caused by: <openjpa-1.0.0-r420667:568756 fatal user
>> error> org.apache.openjpa.util.InvalidStateException: Detected
>> reentrant flush. Make sure your flush-time instance callback methods
>> or event listeners do not invoke any operations that require the in-
>> progress flush to complete.
>> [junit-coverage] at
>> org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:1840)
>> [junit-coverage] at
>> org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:1615)
>> [junit-coverage] at
>> org
>> .apache
>> .openjpa
>> .kernel.StateManagerImpl.assignObjectId(StateManagerImpl.java:
>> 505)
>> [junit-coverage] at
>> org
>> .apache
>> .openjpa.kernel.StateManagerImpl.assignField(StateManagerImpl.java:
>> 590)
>> [junit-coverage] at
>> org
>> .apache
>> .openjpa
>> .kernel.StateManagerImpl.beforeAccessField(StateManagerImpl.java:
>> 1451)
>> [junit-coverage] at
>> org
>> .apache
>> .openjpa
>> .kernel.StateManagerImpl.accessingField(StateManagerImpl.java:
>> 1434)
>> [junit-coverage] at
>> com.joost.model.InventoryItem.getId(InventoryItem.java)
>> [junit-coverage] at
>> com.joost.model.InventoryItem.initPublicIdIfNull(InventoryItem.java:
>> 331)
>>
>>
>> in InventoryItem, getId is the PK, and my read of the spec says
>> that I
>> am guaranteed to have it in @PostPersist.
>>
>> Bug? me doing something wrong?
>>
>> geir
>>
>>
>> Notice: This email message, together with any attachments, may
>> contain information of BEA Systems, Inc., its subsidiaries and
>> affiliated entities, that may be confidential, proprietary,
>> copyrighted and/or legally privileged, and is intended solely for
>> the use of the individual or entity named in this message. If you
>> are not the intended recipient, and have received this message in
>> error, please immediately return this by email and then delete it.
>
>
> Notice: This email message, together with any attachments, may
> contain information of BEA Systems, Inc., its subsidiaries and
> affiliated entities, that may be confidential, proprietary,
> copyrighted and/or legally privileged, and is intended solely for
> the use of the individual or entity named in this message. If you
> are not the intended recipient, and have received this message in
> error, please immediately return this by email and then delete it.
RE: @PostPersist woes
Posted by Pinaki Poddar <pp...@bea.com>.
It is failing on an instance of InventoryItem.getId() -- is it itself
the argument of persist() or an instance navigable from it?
If possible, try application set identity for InventoryItem, not the
provider.
-----Original Message-----
From: Geir Magnusson Jr. [mailto:geir@pobox.com]
Sent: Thursday, November 15, 2007 1:41 PM
To: dev@openjpa.apache.org
Subject: Re: @PostPersist woes
On Nov 15, 2007, at 4:34 PM, Pinaki Poddar wrote:
>> persist() has in it a new, unmanaged entity.
>
> a) If persist(a) is failing on b, what is the cascade type specified
> on relation a.b?
I'm not actually sure that it's failing on b. I guess I can try to
figure that out. I just know that when I change things so that I have
an unmanaged b, it fails.
>
> b) what is the identity definition on b?
> c) if b is using auto-assigned GeneratedValue or its id is being set
> by application?
>
> -----Original Message-----
> From: Geir Magnusson Jr. [mailto:geir@pobox.com]
> Sent: Thursday, November 15, 2007 11:10 AM
> To: dev@openjpa.apache.org
> Subject: @PostPersist woes
>
> Woe is me :)
>
> I'm using @PostPersist to create some kind of machine-generated data
> for entities on insert, and I'm running into the following problem
> when an entity for which I called persist() has in it a new, unmanaged
> entity.
>
> [junit-coverage] Caused by: <openjpa-1.0.0-r420667:568756 fatal user
> error> org.apache.openjpa.util.InvalidStateException: Detected
> reentrant flush. Make sure your flush-time instance callback methods
> or event listeners do not invoke any operations that require the in-
> progress flush to complete.
> [junit-coverage] at
> org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:1840)
> [junit-coverage] at
> org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:1615)
> [junit-coverage] at
> org
> .apache
> .openjpa.kernel.StateManagerImpl.assignObjectId(StateManagerImpl.java:
> 505)
> [junit-coverage] at
> org
> .apache
> .openjpa.kernel.StateManagerImpl.assignField(StateManagerImpl.java:
> 590)
> [junit-coverage] at
> org
> .apache
> .openjpa
> .kernel.StateManagerImpl.beforeAccessField(StateManagerImpl.java:1451)
> [junit-coverage] at
> org
> .apache
> .openjpa.kernel.StateManagerImpl.accessingField(StateManagerImpl.java:
> 1434)
> [junit-coverage] at
> com.joost.model.InventoryItem.getId(InventoryItem.java)
> [junit-coverage] at
> com.joost.model.InventoryItem.initPublicIdIfNull(InventoryItem.java:
> 331)
>
>
> in InventoryItem, getId is the PK, and my read of the spec says that I
> am guaranteed to have it in @PostPersist.
>
> Bug? me doing something wrong?
>
> geir
>
>
> Notice: This email message, together with any attachments, may
> contain information of BEA Systems, Inc., its subsidiaries and
> affiliated entities, that may be confidential, proprietary,
> copyrighted and/or legally privileged, and is intended solely for
> the use of the individual or entity named in this message. If you
> are not the intended recipient, and have received this message in
> error, please immediately return this by email and then delete it.
Notice: This email message, together with any attachments, may contain information of BEA Systems, Inc., its subsidiaries and affiliated entities, that may be confidential, proprietary, copyrighted and/or legally privileged, and is intended solely for the use of the individual or entity named in this message. If you are not the intended recipient, and have received this message in error, please immediately return this by email and then delete it.
Re: @PostPersist woes
Posted by Patrick Linskey <pl...@gmail.com>.
That sounds about right. I'm not disputing the situation; just
striving for a clear problem description.
-Patrick
On Nov 17, 2007 5:18 PM, Geir Magnusson Jr. <ge...@pobox.com> wrote:
> sure but doesn't it boil down to the problem of the nesting of A
> trying to get it's own Id, which triggered the @PostPersist for B,
> which let do the pathos and misery reported?
>
> geir
>
>
> On Nov 17, 2007, at 8:14 PM, Patrick Linskey wrote:
>
> > I'm just pointing out that there is more to your situation than your
> > description to Craig.
> >
> > -Patrick
> >
> > On Nov 17, 2007 5:12 PM, Geir Magnusson Jr. <ge...@pobox.com> wrote:
> >>
> >> On Nov 17, 2007, at 7:49 PM, Patrick Linskey wrote:
> >>
> >>> I think that there was a bit more to it... I think that you were
> >>> also
> >>> trying to do something that required getting the OID during a
> >>> @PostPersist, right?
> >>
> >> I thought I could do that. The spec seems to say that.
> >>
> >> A needs it's own PK. B needs it's own PK. But B doesn't need to
> >> know A's PK for the action it takes in the @PostPersist method.
> >>
> >>
> >>
> >>>
> >>>
> >>> -Patrick
> >>>
> >>> On Nov 17, 2007 12:26 PM, Geir Magnusson Jr. <ge...@pobox.com> wrote:
> >>>>
> >>>> On Nov 16, 2007, at 3:00 PM, Craig L Russell wrote:
> >>>>
> >>>>> Hi Geir,
> >>>>>
> >>>>> It still isn't clear to me what you are trying to accomplish.
> >>>>> Would
> >>>>> it be possible for you to describe what the goal is? (I might have
> >>>>> missed the key idea in earlier posts...)
> >>>>>
> >>>>
> >>>> Persist an object graph in which object A that has a auto-gen PK
> >>>> and a
> >>>> reference to object B, such that object B has a PK and a
> >>>> reference to
> >>>> object A via a FK in table B.
> >>>>
> >>>> I found a workaround for now. I need to see if Hibernate can do
> >>>> this. I think it can. I realize that depending on that isn't
> >>>> portable, but it sure was convenient.
> >>>>
> >>>> geir
> >>>>
> >>>>
> >>>>
> >>>>> Craig
> >>>>>
> >>>>> On Nov 15, 2007, at 1:59 PM, Geir Magnusson Jr. wrote:
> >>>>>
> >>>>>>
> >>>>>> On Nov 15, 2007, at 4:41 PM, Geir Magnusson Jr. wrote:
> >>>>>>
> >>>>>>>
> >>>>>>> On Nov 15, 2007, at 4:34 PM, Pinaki Poddar wrote:
> >>>>>>>
> >>>>>>>>> persist() has in it a new, unmanaged entity.
> >>>>>>>>
> >>>>>>>> a) If persist(a) is failing on b, what is the cascade type
> >>>>>>>> specified on
> >>>>>>>> relation a.b?
> >>>>>>>
> >>>>>>> I'm not actually sure that it's failing on b. I guess I can
> >>>>>>> try to
> >>>>>>> figure that out. I just know that when I change things so
> >>>>>>> that I
> >>>>>>> have an unmanaged b, it fails.
> >>>>>>
> >>>>>> So I put some printlns in my @PostPersist routine, and I see that
> >>>>>> for something w/o the reference to an unmanaged entity, I get a
> >>>>>> sequence like this :
> >>>>>>
> >>>>>> [junit-coverage] ###### 1 I'm a class com.joost.model.show.Show
> >>>>>> [junit-coverage] ###### 2 I'm a class com.joost.model.show.Show
> >>>>>> [junit-coverage] 7996 pu TRACE [main] openjpa.jdbc.SQL - <t
> >>>>>> 9777317, conn 7891417> executing prepstmnt 9148991 INSERT INTO
> >>>>>> APP.INVENTORYITEM (CHANGENUMBER, COID, CREATIONDATE, DELETED,
> >>>>>> FIRSTPUBLICATIONDATE, LASTMODIFICATIONDATE,
> >>>>>> LATESTPUBLICATIONDATE,
> >>>>>> NAME, OKTOPUBLISH, PUBLICID, PUBLISHED, UUID, ITEMTYPE, DAMID,
> >>>>>> OWNERID) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
> >>>>>> [params=(null) null, (null) null, (Timestamp) 2007-11-15
> >>>>>> 16:51:04.42, (int) 0, (null) null, (Timestamp) 2007-11-15
> >>>>>> 16:51:04.42, (null) null, (String) a, (int) 0, (null) null, (int)
> >>>>>> 0, (String) 007ddeca-edff-4657-927f-ce77205c28ef, (String)
> >>>>>> VideoShow, (int) 10, (int) 10]
> >>>>>> [junit-coverage] 7997 pu TRACE [main] openjpa.jdbc.SQL - <t
> >>>>>> 9777317, conn 7891417> [1 ms] spent
> >>>>>> [junit-coverage] 7997 pu TRACE [main] openjpa.jdbc.SQL - <t
> >>>>>> 9777317, conn 7891417> executing prepstmnt 13415937
> >>>>>> VALUES(IDENTITY_VAL_LOCAL())
> >>>>>> [junit-coverage] 7997 pu TRACE [main] openjpa.jdbc.SQL - <t
> >>>>>> 9777317, conn 7891417> [0 ms] spent
> >>>>>> [junit-coverage] 8004 pu TRACE [main] openjpa.jdbc.SQL - <t
> >>>>>> 9777317, conn 7891417> executing prepstmnt 6406303 INSERT INTO
> >>>>>> APP.VIDEOSHOW (ID, ADSFREE, CODURATION, COFILENAME,
> >>>>>> MAINDESCRIPTION, MAINTITLE, MINAGE, PRODUCTIONYEARS,
> >>>>>> ISPROMOTIONAL,
> >>>>>> RIGHTS, VALIDFROM, VALIDTO, ADVERTISINGSHOWINFOID,
> >>>>>> GEORIGHTSKINDCODE, MAINCHANNELID, MAINDESCRIPTIONLANGUAGECODE,
> >>>>>> MAINTITLELANGUAGECODE, OVERLAYID, SELECTEDTHUMBNAILID) VALUES
> >>>>>> (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
> >>>>>> [params=(int) 74, (int) 0, (null) null, (null) null, (null) null,
> >>>>>> (null) null, (null) null, (null) null, (int) 0, (null) null,
> >>>>>> (null)
> >>>>>> null, (null) null, (null) null, (int) 3, (null) null, (null)
> >>>>>> null,
> >>>>>> (null) null, (null) null, (null) null]
> >>>>>> [junit-coverage] 8006 pu TRACE [main] openjpa.jdbc.SQL - <t
> >>>>>> 9777317, conn 7891417> [2 ms] spent
> >>>>>> [junit-coverage] ###### 3 I'm a class com.joost.model.show.Show
> >>>>>> [junit-coverage] ###### 4 I'm a class com.joost.model.show.Show
> >>>>>>
> >>>>>> The code after the ###### 2 message is a getId(), and that
> >>>>>> triggers
> >>>>>> the write to the db. You can see that we write to both
> >>>>>> InventoryItem (the base class) and then VideoShow (java class
> >>>>>> Show
> >>>>>> maps to the VideoShow table... public class Show extends
> >>>>>> InventoryItem)
> >>>>>>
> >>>>>> However, for the case of "b" within "a", which is a ChannelItem
> >>>>>> within a Channel (both of which extend InventoryItem) I get :
> >>>>>>
> >>>>>> [junit-coverage] ###### 1 I'm a class
> >>>>>> com.joost.model.channel.Channel
> >>>>>> [junit-coverage] ###### 2 I'm a class
> >>>>>> com.joost.model.channel.Channel
> >>>>>> [junit-coverage] ###### 1 I'm a class com.joost.model.ChannelItem
> >>>>>> [junit-coverage] ###### 2 I'm a class com.joost.model.ChannelItem
> >>>>>> [junit-coverage] Nov 15, 2007 4:51:04 PM
> >>>>>> org.springframework.test.AbstractTransactionalSpringContextTests
> >>>>>> endTransaction
> >>>>>> [junit-coverage] INFO: Rolled back transaction after test
> >>>>>> execution
> >>>>>> [junit-coverage] ------------- ---------------- ---------------
> >>>>>> <EXCEPTION>
> >>>>>>
> >>>>>> so the getId() for the Channel ("a") called after the #### 2
> >>>>>> message triggers the @PostPersist for the ChannelItem ("b") which
> >>>>>> has a reference to the id for Channel. I think that therefore I
> >>>>>> can conclude that what I'm doing is illegal according to the spec
> >>>>>>
> >>>>>> 3.5.2 : It isimplementation-dependent as to whether callback
> >>>>>> methods are invoked before or after the cascading of the
> >>>>>> lifecycle
> >>>>>> events to related entities. Applications should not depend on
> >>>>>> this
> >>>>>> ordering.
> >>>>>>
> >>>>>> and therefore if that's true, I'm sorry for wasting your time :)
> >>>>>>
> >>>>>> Anyone have a clue how I can get out of this mess?
> >>>>>>
> >>>>>> geir
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>>
> >>>>>>>> b) what is the identity definition on b?
> >>>>>>>> c) if b is using auto-assigned GeneratedValue or its id is
> >>>>>>>> being
> >>>>>>>> set by
> >>>>>>>> application?
> >>>>>>>>
> >>>>>>>> -----Original Message-----
> >>>>>>>> From: Geir Magnusson Jr. [mailto:geir@pobox.com]
> >>>>>>>> Sent: Thursday, November 15, 2007 11:10 AM
> >>>>>>>> To: dev@openjpa.apache.org
> >>>>>>>> Subject: @PostPersist woes
> >>>>>>>>
> >>>>>>>> Woe is me :)
> >>>>>>>>
> >>>>>>>> I'm using @PostPersist to create some kind of machine-generated
> >>>>>>>> data for
> >>>>>>>> entities on insert, and I'm running into the following problem
> >>>>>>>> when an
> >>>>>>>> entity for which I called persist() has in it a new, unmanaged
> >>>>>>>> entity.
> >>>>>>>>
> >>>>>>>> [junit-coverage] Caused by: <openjpa-1.0.0-r420667:568756 fatal
> >>>>>>>> user
> >>>>>>>> error> org.apache.openjpa.util.InvalidStateException: Detected
> >>>>>>>> reentrant flush. Make sure your flush-time instance callback
> >>>>>>>> methods or
> >>>>>>>> event listeners do not invoke any operations that require the
> >>>>>>>> in-
> >>>>>>>> progress flush to complete.
> >>>>>>>> [junit-coverage] at
> >>>>>>>> org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:
> >>>>>>>> 1840)
> >>>>>>>> [junit-coverage] at
> >>>>>>>> org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:
> >>>>>>>> 1615)
> >>>>>>>> [junit-coverage] at
> >>>>>>>> org
> >>>>>>>> .apache
> >>>>>>>> .openjpa
> >>>>>>>> .kernel.StateManagerImpl.assignObjectId(StateManagerImpl.java:
> >>>>>>>> 505)
> >>>>>>>> [junit-coverage] at
> >>>>>>>> org
> >>>>>>>> .apache
> >>>>>>>> .openjpa
> >>>>>>>> .kernel.StateManagerImpl.assignField(StateManagerImpl.java:590)
> >>>>>>>> [junit-coverage] at
> >>>>>>>> org
> >>>>>>>> .apache
> >>>>>>>> .openjpa
> >>>>>>>> .kernel
> >>>>>>>> .StateManagerImpl.beforeAccessField(StateManagerImpl.java:
> >>>>>>>> 1451)
> >>>>>>>> [junit-coverage] at
> >>>>>>>> org
> >>>>>>>> .apache
> >>>>>>>> .openjpa
> >>>>>>>> .kernel.StateManagerImpl.accessingField(StateManagerImpl.java:
> >>>>>>>> 1434)
> >>>>>>>> [junit-coverage] at
> >>>>>>>> com.joost.model.InventoryItem.getId(InventoryItem.java)
> >>>>>>>> [junit-coverage] at
> >>>>>>>> com
> >>>>>>>> .joost
> >>>>>>>> .model.InventoryItem.initPublicIdIfNull(InventoryItem.java:
> >>>>>>>> 331)
> >>>>>>>>
> >>>>>>>>
> >>>>>>>> in InventoryItem, getId is the PK, and my read of the spec says
> >>>>>>>> that I
> >>>>>>>> am guaranteed to have it in @PostPersist.
> >>>>>>>>
> >>>>>>>> Bug? me doing something wrong?
> >>>>>>>>
> >>>>>>>> geir
> >>>>>>>>
> >>>>>>>>
> >>>>>>>> Notice: This email message, together with any attachments, may
> >>>>>>>> contain information of BEA Systems, Inc., its subsidiaries
> >>>>>>>> and affiliated entities, that may be confidential,
> >>>>>>>> proprietary, copyrighted and/or legally privileged, and is
> >>>>>>>> intended solely for the use of the individual or entity named
> >>>>>>>> in
> >>>>>>>> this message. If you are not the intended recipient, and have
> >>>>>>>> received this message in error, please immediately return
> >>>>>>>> this by
> >>>>>>>> email and then delete it.
> >>>>>>>
> >>>>>>
> >>>>>
> >>>>> Craig Russell
> >>>>> Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
> >>>>> 408 276-5638 mailto:Craig.Russell@sun.com
> >>>>> P.S. A good JDO? O, Gasp!
> >>>>>
> >>>>
> >>>>
> >>>
> >>>
> >>>
> >>> --
> >>> Patrick Linskey
> >>> 202 669 5907
> >>
> >>
> >
> >
> >
> > --
> > Patrick Linskey
> > 202 669 5907
>
>
--
Patrick Linskey
202 669 5907
Re: @PostPersist woes
Posted by "Geir Magnusson Jr." <ge...@pobox.com>.
sure but doesn't it boil down to the problem of the nesting of A
trying to get it's own Id, which triggered the @PostPersist for B,
which let do the pathos and misery reported?
geir
On Nov 17, 2007, at 8:14 PM, Patrick Linskey wrote:
> I'm just pointing out that there is more to your situation than your
> description to Craig.
>
> -Patrick
>
> On Nov 17, 2007 5:12 PM, Geir Magnusson Jr. <ge...@pobox.com> wrote:
>>
>> On Nov 17, 2007, at 7:49 PM, Patrick Linskey wrote:
>>
>>> I think that there was a bit more to it... I think that you were
>>> also
>>> trying to do something that required getting the OID during a
>>> @PostPersist, right?
>>
>> I thought I could do that. The spec seems to say that.
>>
>> A needs it's own PK. B needs it's own PK. But B doesn't need to
>> know A's PK for the action it takes in the @PostPersist method.
>>
>>
>>
>>>
>>>
>>> -Patrick
>>>
>>> On Nov 17, 2007 12:26 PM, Geir Magnusson Jr. <ge...@pobox.com> wrote:
>>>>
>>>> On Nov 16, 2007, at 3:00 PM, Craig L Russell wrote:
>>>>
>>>>> Hi Geir,
>>>>>
>>>>> It still isn't clear to me what you are trying to accomplish.
>>>>> Would
>>>>> it be possible for you to describe what the goal is? (I might have
>>>>> missed the key idea in earlier posts...)
>>>>>
>>>>
>>>> Persist an object graph in which object A that has a auto-gen PK
>>>> and a
>>>> reference to object B, such that object B has a PK and a
>>>> reference to
>>>> object A via a FK in table B.
>>>>
>>>> I found a workaround for now. I need to see if Hibernate can do
>>>> this. I think it can. I realize that depending on that isn't
>>>> portable, but it sure was convenient.
>>>>
>>>> geir
>>>>
>>>>
>>>>
>>>>> Craig
>>>>>
>>>>> On Nov 15, 2007, at 1:59 PM, Geir Magnusson Jr. wrote:
>>>>>
>>>>>>
>>>>>> On Nov 15, 2007, at 4:41 PM, Geir Magnusson Jr. wrote:
>>>>>>
>>>>>>>
>>>>>>> On Nov 15, 2007, at 4:34 PM, Pinaki Poddar wrote:
>>>>>>>
>>>>>>>>> persist() has in it a new, unmanaged entity.
>>>>>>>>
>>>>>>>> a) If persist(a) is failing on b, what is the cascade type
>>>>>>>> specified on
>>>>>>>> relation a.b?
>>>>>>>
>>>>>>> I'm not actually sure that it's failing on b. I guess I can
>>>>>>> try to
>>>>>>> figure that out. I just know that when I change things so
>>>>>>> that I
>>>>>>> have an unmanaged b, it fails.
>>>>>>
>>>>>> So I put some printlns in my @PostPersist routine, and I see that
>>>>>> for something w/o the reference to an unmanaged entity, I get a
>>>>>> sequence like this :
>>>>>>
>>>>>> [junit-coverage] ###### 1 I'm a class com.joost.model.show.Show
>>>>>> [junit-coverage] ###### 2 I'm a class com.joost.model.show.Show
>>>>>> [junit-coverage] 7996 pu TRACE [main] openjpa.jdbc.SQL - <t
>>>>>> 9777317, conn 7891417> executing prepstmnt 9148991 INSERT INTO
>>>>>> APP.INVENTORYITEM (CHANGENUMBER, COID, CREATIONDATE, DELETED,
>>>>>> FIRSTPUBLICATIONDATE, LASTMODIFICATIONDATE,
>>>>>> LATESTPUBLICATIONDATE,
>>>>>> NAME, OKTOPUBLISH, PUBLICID, PUBLISHED, UUID, ITEMTYPE, DAMID,
>>>>>> OWNERID) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
>>>>>> [params=(null) null, (null) null, (Timestamp) 2007-11-15
>>>>>> 16:51:04.42, (int) 0, (null) null, (Timestamp) 2007-11-15
>>>>>> 16:51:04.42, (null) null, (String) a, (int) 0, (null) null, (int)
>>>>>> 0, (String) 007ddeca-edff-4657-927f-ce77205c28ef, (String)
>>>>>> VideoShow, (int) 10, (int) 10]
>>>>>> [junit-coverage] 7997 pu TRACE [main] openjpa.jdbc.SQL - <t
>>>>>> 9777317, conn 7891417> [1 ms] spent
>>>>>> [junit-coverage] 7997 pu TRACE [main] openjpa.jdbc.SQL - <t
>>>>>> 9777317, conn 7891417> executing prepstmnt 13415937
>>>>>> VALUES(IDENTITY_VAL_LOCAL())
>>>>>> [junit-coverage] 7997 pu TRACE [main] openjpa.jdbc.SQL - <t
>>>>>> 9777317, conn 7891417> [0 ms] spent
>>>>>> [junit-coverage] 8004 pu TRACE [main] openjpa.jdbc.SQL - <t
>>>>>> 9777317, conn 7891417> executing prepstmnt 6406303 INSERT INTO
>>>>>> APP.VIDEOSHOW (ID, ADSFREE, CODURATION, COFILENAME,
>>>>>> MAINDESCRIPTION, MAINTITLE, MINAGE, PRODUCTIONYEARS,
>>>>>> ISPROMOTIONAL,
>>>>>> RIGHTS, VALIDFROM, VALIDTO, ADVERTISINGSHOWINFOID,
>>>>>> GEORIGHTSKINDCODE, MAINCHANNELID, MAINDESCRIPTIONLANGUAGECODE,
>>>>>> MAINTITLELANGUAGECODE, OVERLAYID, SELECTEDTHUMBNAILID) VALUES
>>>>>> (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
>>>>>> [params=(int) 74, (int) 0, (null) null, (null) null, (null) null,
>>>>>> (null) null, (null) null, (null) null, (int) 0, (null) null,
>>>>>> (null)
>>>>>> null, (null) null, (null) null, (int) 3, (null) null, (null)
>>>>>> null,
>>>>>> (null) null, (null) null, (null) null]
>>>>>> [junit-coverage] 8006 pu TRACE [main] openjpa.jdbc.SQL - <t
>>>>>> 9777317, conn 7891417> [2 ms] spent
>>>>>> [junit-coverage] ###### 3 I'm a class com.joost.model.show.Show
>>>>>> [junit-coverage] ###### 4 I'm a class com.joost.model.show.Show
>>>>>>
>>>>>> The code after the ###### 2 message is a getId(), and that
>>>>>> triggers
>>>>>> the write to the db. You can see that we write to both
>>>>>> InventoryItem (the base class) and then VideoShow (java class
>>>>>> Show
>>>>>> maps to the VideoShow table... public class Show extends
>>>>>> InventoryItem)
>>>>>>
>>>>>> However, for the case of "b" within "a", which is a ChannelItem
>>>>>> within a Channel (both of which extend InventoryItem) I get :
>>>>>>
>>>>>> [junit-coverage] ###### 1 I'm a class
>>>>>> com.joost.model.channel.Channel
>>>>>> [junit-coverage] ###### 2 I'm a class
>>>>>> com.joost.model.channel.Channel
>>>>>> [junit-coverage] ###### 1 I'm a class com.joost.model.ChannelItem
>>>>>> [junit-coverage] ###### 2 I'm a class com.joost.model.ChannelItem
>>>>>> [junit-coverage] Nov 15, 2007 4:51:04 PM
>>>>>> org.springframework.test.AbstractTransactionalSpringContextTests
>>>>>> endTransaction
>>>>>> [junit-coverage] INFO: Rolled back transaction after test
>>>>>> execution
>>>>>> [junit-coverage] ------------- ---------------- ---------------
>>>>>> <EXCEPTION>
>>>>>>
>>>>>> so the getId() for the Channel ("a") called after the #### 2
>>>>>> message triggers the @PostPersist for the ChannelItem ("b") which
>>>>>> has a reference to the id for Channel. I think that therefore I
>>>>>> can conclude that what I'm doing is illegal according to the spec
>>>>>>
>>>>>> 3.5.2 : It isimplementation-dependent as to whether callback
>>>>>> methods are invoked before or after the cascading of the
>>>>>> lifecycle
>>>>>> events to related entities. Applications should not depend on
>>>>>> this
>>>>>> ordering.
>>>>>>
>>>>>> and therefore if that's true, I'm sorry for wasting your time :)
>>>>>>
>>>>>> Anyone have a clue how I can get out of this mess?
>>>>>>
>>>>>> geir
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>>
>>>>>>>> b) what is the identity definition on b?
>>>>>>>> c) if b is using auto-assigned GeneratedValue or its id is
>>>>>>>> being
>>>>>>>> set by
>>>>>>>> application?
>>>>>>>>
>>>>>>>> -----Original Message-----
>>>>>>>> From: Geir Magnusson Jr. [mailto:geir@pobox.com]
>>>>>>>> Sent: Thursday, November 15, 2007 11:10 AM
>>>>>>>> To: dev@openjpa.apache.org
>>>>>>>> Subject: @PostPersist woes
>>>>>>>>
>>>>>>>> Woe is me :)
>>>>>>>>
>>>>>>>> I'm using @PostPersist to create some kind of machine-generated
>>>>>>>> data for
>>>>>>>> entities on insert, and I'm running into the following problem
>>>>>>>> when an
>>>>>>>> entity for which I called persist() has in it a new, unmanaged
>>>>>>>> entity.
>>>>>>>>
>>>>>>>> [junit-coverage] Caused by: <openjpa-1.0.0-r420667:568756 fatal
>>>>>>>> user
>>>>>>>> error> org.apache.openjpa.util.InvalidStateException: Detected
>>>>>>>> reentrant flush. Make sure your flush-time instance callback
>>>>>>>> methods or
>>>>>>>> event listeners do not invoke any operations that require the
>>>>>>>> in-
>>>>>>>> progress flush to complete.
>>>>>>>> [junit-coverage] at
>>>>>>>> org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:
>>>>>>>> 1840)
>>>>>>>> [junit-coverage] at
>>>>>>>> org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:
>>>>>>>> 1615)
>>>>>>>> [junit-coverage] at
>>>>>>>> org
>>>>>>>> .apache
>>>>>>>> .openjpa
>>>>>>>> .kernel.StateManagerImpl.assignObjectId(StateManagerImpl.java:
>>>>>>>> 505)
>>>>>>>> [junit-coverage] at
>>>>>>>> org
>>>>>>>> .apache
>>>>>>>> .openjpa
>>>>>>>> .kernel.StateManagerImpl.assignField(StateManagerImpl.java:590)
>>>>>>>> [junit-coverage] at
>>>>>>>> org
>>>>>>>> .apache
>>>>>>>> .openjpa
>>>>>>>> .kernel
>>>>>>>> .StateManagerImpl.beforeAccessField(StateManagerImpl.java:
>>>>>>>> 1451)
>>>>>>>> [junit-coverage] at
>>>>>>>> org
>>>>>>>> .apache
>>>>>>>> .openjpa
>>>>>>>> .kernel.StateManagerImpl.accessingField(StateManagerImpl.java:
>>>>>>>> 1434)
>>>>>>>> [junit-coverage] at
>>>>>>>> com.joost.model.InventoryItem.getId(InventoryItem.java)
>>>>>>>> [junit-coverage] at
>>>>>>>> com
>>>>>>>> .joost
>>>>>>>> .model.InventoryItem.initPublicIdIfNull(InventoryItem.java:
>>>>>>>> 331)
>>>>>>>>
>>>>>>>>
>>>>>>>> in InventoryItem, getId is the PK, and my read of the spec says
>>>>>>>> that I
>>>>>>>> am guaranteed to have it in @PostPersist.
>>>>>>>>
>>>>>>>> Bug? me doing something wrong?
>>>>>>>>
>>>>>>>> geir
>>>>>>>>
>>>>>>>>
>>>>>>>> Notice: This email message, together with any attachments, may
>>>>>>>> contain information of BEA Systems, Inc., its subsidiaries
>>>>>>>> and affiliated entities, that may be confidential,
>>>>>>>> proprietary, copyrighted and/or legally privileged, and is
>>>>>>>> intended solely for the use of the individual or entity named
>>>>>>>> in
>>>>>>>> this message. If you are not the intended recipient, and have
>>>>>>>> received this message in error, please immediately return
>>>>>>>> this by
>>>>>>>> email and then delete it.
>>>>>>>
>>>>>>
>>>>>
>>>>> Craig Russell
>>>>> Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
>>>>> 408 276-5638 mailto:Craig.Russell@sun.com
>>>>> P.S. A good JDO? O, Gasp!
>>>>>
>>>>
>>>>
>>>
>>>
>>>
>>> --
>>> Patrick Linskey
>>> 202 669 5907
>>
>>
>
>
>
> --
> Patrick Linskey
> 202 669 5907
Re: @PostPersist woes
Posted by Patrick Linskey <pl...@gmail.com>.
I'm just pointing out that there is more to your situation than your
description to Craig.
-Patrick
On Nov 17, 2007 5:12 PM, Geir Magnusson Jr. <ge...@pobox.com> wrote:
>
> On Nov 17, 2007, at 7:49 PM, Patrick Linskey wrote:
>
> > I think that there was a bit more to it... I think that you were also
> > trying to do something that required getting the OID during a
> > @PostPersist, right?
>
> I thought I could do that. The spec seems to say that.
>
> A needs it's own PK. B needs it's own PK. But B doesn't need to
> know A's PK for the action it takes in the @PostPersist method.
>
>
>
> >
> >
> > -Patrick
> >
> > On Nov 17, 2007 12:26 PM, Geir Magnusson Jr. <ge...@pobox.com> wrote:
> >>
> >> On Nov 16, 2007, at 3:00 PM, Craig L Russell wrote:
> >>
> >>> Hi Geir,
> >>>
> >>> It still isn't clear to me what you are trying to accomplish. Would
> >>> it be possible for you to describe what the goal is? (I might have
> >>> missed the key idea in earlier posts...)
> >>>
> >>
> >> Persist an object graph in which object A that has a auto-gen PK
> >> and a
> >> reference to object B, such that object B has a PK and a reference to
> >> object A via a FK in table B.
> >>
> >> I found a workaround for now. I need to see if Hibernate can do
> >> this. I think it can. I realize that depending on that isn't
> >> portable, but it sure was convenient.
> >>
> >> geir
> >>
> >>
> >>
> >>> Craig
> >>>
> >>> On Nov 15, 2007, at 1:59 PM, Geir Magnusson Jr. wrote:
> >>>
> >>>>
> >>>> On Nov 15, 2007, at 4:41 PM, Geir Magnusson Jr. wrote:
> >>>>
> >>>>>
> >>>>> On Nov 15, 2007, at 4:34 PM, Pinaki Poddar wrote:
> >>>>>
> >>>>>>> persist() has in it a new, unmanaged entity.
> >>>>>>
> >>>>>> a) If persist(a) is failing on b, what is the cascade type
> >>>>>> specified on
> >>>>>> relation a.b?
> >>>>>
> >>>>> I'm not actually sure that it's failing on b. I guess I can try to
> >>>>> figure that out. I just know that when I change things so that I
> >>>>> have an unmanaged b, it fails.
> >>>>
> >>>> So I put some printlns in my @PostPersist routine, and I see that
> >>>> for something w/o the reference to an unmanaged entity, I get a
> >>>> sequence like this :
> >>>>
> >>>> [junit-coverage] ###### 1 I'm a class com.joost.model.show.Show
> >>>> [junit-coverage] ###### 2 I'm a class com.joost.model.show.Show
> >>>> [junit-coverage] 7996 pu TRACE [main] openjpa.jdbc.SQL - <t
> >>>> 9777317, conn 7891417> executing prepstmnt 9148991 INSERT INTO
> >>>> APP.INVENTORYITEM (CHANGENUMBER, COID, CREATIONDATE, DELETED,
> >>>> FIRSTPUBLICATIONDATE, LASTMODIFICATIONDATE, LATESTPUBLICATIONDATE,
> >>>> NAME, OKTOPUBLISH, PUBLICID, PUBLISHED, UUID, ITEMTYPE, DAMID,
> >>>> OWNERID) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
> >>>> [params=(null) null, (null) null, (Timestamp) 2007-11-15
> >>>> 16:51:04.42, (int) 0, (null) null, (Timestamp) 2007-11-15
> >>>> 16:51:04.42, (null) null, (String) a, (int) 0, (null) null, (int)
> >>>> 0, (String) 007ddeca-edff-4657-927f-ce77205c28ef, (String)
> >>>> VideoShow, (int) 10, (int) 10]
> >>>> [junit-coverage] 7997 pu TRACE [main] openjpa.jdbc.SQL - <t
> >>>> 9777317, conn 7891417> [1 ms] spent
> >>>> [junit-coverage] 7997 pu TRACE [main] openjpa.jdbc.SQL - <t
> >>>> 9777317, conn 7891417> executing prepstmnt 13415937
> >>>> VALUES(IDENTITY_VAL_LOCAL())
> >>>> [junit-coverage] 7997 pu TRACE [main] openjpa.jdbc.SQL - <t
> >>>> 9777317, conn 7891417> [0 ms] spent
> >>>> [junit-coverage] 8004 pu TRACE [main] openjpa.jdbc.SQL - <t
> >>>> 9777317, conn 7891417> executing prepstmnt 6406303 INSERT INTO
> >>>> APP.VIDEOSHOW (ID, ADSFREE, CODURATION, COFILENAME,
> >>>> MAINDESCRIPTION, MAINTITLE, MINAGE, PRODUCTIONYEARS, ISPROMOTIONAL,
> >>>> RIGHTS, VALIDFROM, VALIDTO, ADVERTISINGSHOWINFOID,
> >>>> GEORIGHTSKINDCODE, MAINCHANNELID, MAINDESCRIPTIONLANGUAGECODE,
> >>>> MAINTITLELANGUAGECODE, OVERLAYID, SELECTEDTHUMBNAILID) VALUES
> >>>> (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
> >>>> [params=(int) 74, (int) 0, (null) null, (null) null, (null) null,
> >>>> (null) null, (null) null, (null) null, (int) 0, (null) null, (null)
> >>>> null, (null) null, (null) null, (int) 3, (null) null, (null) null,
> >>>> (null) null, (null) null, (null) null]
> >>>> [junit-coverage] 8006 pu TRACE [main] openjpa.jdbc.SQL - <t
> >>>> 9777317, conn 7891417> [2 ms] spent
> >>>> [junit-coverage] ###### 3 I'm a class com.joost.model.show.Show
> >>>> [junit-coverage] ###### 4 I'm a class com.joost.model.show.Show
> >>>>
> >>>> The code after the ###### 2 message is a getId(), and that triggers
> >>>> the write to the db. You can see that we write to both
> >>>> InventoryItem (the base class) and then VideoShow (java class Show
> >>>> maps to the VideoShow table... public class Show extends
> >>>> InventoryItem)
> >>>>
> >>>> However, for the case of "b" within "a", which is a ChannelItem
> >>>> within a Channel (both of which extend InventoryItem) I get :
> >>>>
> >>>> [junit-coverage] ###### 1 I'm a class
> >>>> com.joost.model.channel.Channel
> >>>> [junit-coverage] ###### 2 I'm a class
> >>>> com.joost.model.channel.Channel
> >>>> [junit-coverage] ###### 1 I'm a class com.joost.model.ChannelItem
> >>>> [junit-coverage] ###### 2 I'm a class com.joost.model.ChannelItem
> >>>> [junit-coverage] Nov 15, 2007 4:51:04 PM
> >>>> org.springframework.test.AbstractTransactionalSpringContextTests
> >>>> endTransaction
> >>>> [junit-coverage] INFO: Rolled back transaction after test execution
> >>>> [junit-coverage] ------------- ---------------- ---------------
> >>>> <EXCEPTION>
> >>>>
> >>>> so the getId() for the Channel ("a") called after the #### 2
> >>>> message triggers the @PostPersist for the ChannelItem ("b") which
> >>>> has a reference to the id for Channel. I think that therefore I
> >>>> can conclude that what I'm doing is illegal according to the spec
> >>>>
> >>>> 3.5.2 : It isimplementation-dependent as to whether callback
> >>>> methods are invoked before or after the cascading of the lifecycle
> >>>> events to related entities. Applications should not depend on this
> >>>> ordering.
> >>>>
> >>>> and therefore if that's true, I'm sorry for wasting your time :)
> >>>>
> >>>> Anyone have a clue how I can get out of this mess?
> >>>>
> >>>> geir
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>>
> >>>>>
> >>>>>>
> >>>>>> b) what is the identity definition on b?
> >>>>>> c) if b is using auto-assigned GeneratedValue or its id is being
> >>>>>> set by
> >>>>>> application?
> >>>>>>
> >>>>>> -----Original Message-----
> >>>>>> From: Geir Magnusson Jr. [mailto:geir@pobox.com]
> >>>>>> Sent: Thursday, November 15, 2007 11:10 AM
> >>>>>> To: dev@openjpa.apache.org
> >>>>>> Subject: @PostPersist woes
> >>>>>>
> >>>>>> Woe is me :)
> >>>>>>
> >>>>>> I'm using @PostPersist to create some kind of machine-generated
> >>>>>> data for
> >>>>>> entities on insert, and I'm running into the following problem
> >>>>>> when an
> >>>>>> entity for which I called persist() has in it a new, unmanaged
> >>>>>> entity.
> >>>>>>
> >>>>>> [junit-coverage] Caused by: <openjpa-1.0.0-r420667:568756 fatal
> >>>>>> user
> >>>>>> error> org.apache.openjpa.util.InvalidStateException: Detected
> >>>>>> reentrant flush. Make sure your flush-time instance callback
> >>>>>> methods or
> >>>>>> event listeners do not invoke any operations that require the in-
> >>>>>> progress flush to complete.
> >>>>>> [junit-coverage] at
> >>>>>> org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:
> >>>>>> 1840)
> >>>>>> [junit-coverage] at
> >>>>>> org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:1615)
> >>>>>> [junit-coverage] at
> >>>>>> org
> >>>>>> .apache
> >>>>>> .openjpa
> >>>>>> .kernel.StateManagerImpl.assignObjectId(StateManagerImpl.java:
> >>>>>> 505)
> >>>>>> [junit-coverage] at
> >>>>>> org
> >>>>>> .apache
> >>>>>> .openjpa
> >>>>>> .kernel.StateManagerImpl.assignField(StateManagerImpl.java:590)
> >>>>>> [junit-coverage] at
> >>>>>> org
> >>>>>> .apache
> >>>>>> .openjpa
> >>>>>> .kernel.StateManagerImpl.beforeAccessField(StateManagerImpl.java:
> >>>>>> 1451)
> >>>>>> [junit-coverage] at
> >>>>>> org
> >>>>>> .apache
> >>>>>> .openjpa
> >>>>>> .kernel.StateManagerImpl.accessingField(StateManagerImpl.java:
> >>>>>> 1434)
> >>>>>> [junit-coverage] at
> >>>>>> com.joost.model.InventoryItem.getId(InventoryItem.java)
> >>>>>> [junit-coverage] at
> >>>>>> com
> >>>>>> .joost.model.InventoryItem.initPublicIdIfNull(InventoryItem.java:
> >>>>>> 331)
> >>>>>>
> >>>>>>
> >>>>>> in InventoryItem, getId is the PK, and my read of the spec says
> >>>>>> that I
> >>>>>> am guaranteed to have it in @PostPersist.
> >>>>>>
> >>>>>> Bug? me doing something wrong?
> >>>>>>
> >>>>>> geir
> >>>>>>
> >>>>>>
> >>>>>> Notice: This email message, together with any attachments, may
> >>>>>> contain information of BEA Systems, Inc., its subsidiaries
> >>>>>> and affiliated entities, that may be confidential,
> >>>>>> proprietary, copyrighted and/or legally privileged, and is
> >>>>>> intended solely for the use of the individual or entity named in
> >>>>>> this message. If you are not the intended recipient, and have
> >>>>>> received this message in error, please immediately return this by
> >>>>>> email and then delete it.
> >>>>>
> >>>>
> >>>
> >>> Craig Russell
> >>> Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
> >>> 408 276-5638 mailto:Craig.Russell@sun.com
> >>> P.S. A good JDO? O, Gasp!
> >>>
> >>
> >>
> >
> >
> >
> > --
> > Patrick Linskey
> > 202 669 5907
>
>
--
Patrick Linskey
202 669 5907
Re: @PostPersist woes
Posted by "Geir Magnusson Jr." <ge...@pobox.com>.
On Nov 17, 2007, at 7:49 PM, Patrick Linskey wrote:
> I think that there was a bit more to it... I think that you were also
> trying to do something that required getting the OID during a
> @PostPersist, right?
I thought I could do that. The spec seems to say that.
A needs it's own PK. B needs it's own PK. But B doesn't need to
know A's PK for the action it takes in the @PostPersist method.
>
>
> -Patrick
>
> On Nov 17, 2007 12:26 PM, Geir Magnusson Jr. <ge...@pobox.com> wrote:
>>
>> On Nov 16, 2007, at 3:00 PM, Craig L Russell wrote:
>>
>>> Hi Geir,
>>>
>>> It still isn't clear to me what you are trying to accomplish. Would
>>> it be possible for you to describe what the goal is? (I might have
>>> missed the key idea in earlier posts...)
>>>
>>
>> Persist an object graph in which object A that has a auto-gen PK
>> and a
>> reference to object B, such that object B has a PK and a reference to
>> object A via a FK in table B.
>>
>> I found a workaround for now. I need to see if Hibernate can do
>> this. I think it can. I realize that depending on that isn't
>> portable, but it sure was convenient.
>>
>> geir
>>
>>
>>
>>> Craig
>>>
>>> On Nov 15, 2007, at 1:59 PM, Geir Magnusson Jr. wrote:
>>>
>>>>
>>>> On Nov 15, 2007, at 4:41 PM, Geir Magnusson Jr. wrote:
>>>>
>>>>>
>>>>> On Nov 15, 2007, at 4:34 PM, Pinaki Poddar wrote:
>>>>>
>>>>>>> persist() has in it a new, unmanaged entity.
>>>>>>
>>>>>> a) If persist(a) is failing on b, what is the cascade type
>>>>>> specified on
>>>>>> relation a.b?
>>>>>
>>>>> I'm not actually sure that it's failing on b. I guess I can try to
>>>>> figure that out. I just know that when I change things so that I
>>>>> have an unmanaged b, it fails.
>>>>
>>>> So I put some printlns in my @PostPersist routine, and I see that
>>>> for something w/o the reference to an unmanaged entity, I get a
>>>> sequence like this :
>>>>
>>>> [junit-coverage] ###### 1 I'm a class com.joost.model.show.Show
>>>> [junit-coverage] ###### 2 I'm a class com.joost.model.show.Show
>>>> [junit-coverage] 7996 pu TRACE [main] openjpa.jdbc.SQL - <t
>>>> 9777317, conn 7891417> executing prepstmnt 9148991 INSERT INTO
>>>> APP.INVENTORYITEM (CHANGENUMBER, COID, CREATIONDATE, DELETED,
>>>> FIRSTPUBLICATIONDATE, LASTMODIFICATIONDATE, LATESTPUBLICATIONDATE,
>>>> NAME, OKTOPUBLISH, PUBLICID, PUBLISHED, UUID, ITEMTYPE, DAMID,
>>>> OWNERID) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
>>>> [params=(null) null, (null) null, (Timestamp) 2007-11-15
>>>> 16:51:04.42, (int) 0, (null) null, (Timestamp) 2007-11-15
>>>> 16:51:04.42, (null) null, (String) a, (int) 0, (null) null, (int)
>>>> 0, (String) 007ddeca-edff-4657-927f-ce77205c28ef, (String)
>>>> VideoShow, (int) 10, (int) 10]
>>>> [junit-coverage] 7997 pu TRACE [main] openjpa.jdbc.SQL - <t
>>>> 9777317, conn 7891417> [1 ms] spent
>>>> [junit-coverage] 7997 pu TRACE [main] openjpa.jdbc.SQL - <t
>>>> 9777317, conn 7891417> executing prepstmnt 13415937
>>>> VALUES(IDENTITY_VAL_LOCAL())
>>>> [junit-coverage] 7997 pu TRACE [main] openjpa.jdbc.SQL - <t
>>>> 9777317, conn 7891417> [0 ms] spent
>>>> [junit-coverage] 8004 pu TRACE [main] openjpa.jdbc.SQL - <t
>>>> 9777317, conn 7891417> executing prepstmnt 6406303 INSERT INTO
>>>> APP.VIDEOSHOW (ID, ADSFREE, CODURATION, COFILENAME,
>>>> MAINDESCRIPTION, MAINTITLE, MINAGE, PRODUCTIONYEARS, ISPROMOTIONAL,
>>>> RIGHTS, VALIDFROM, VALIDTO, ADVERTISINGSHOWINFOID,
>>>> GEORIGHTSKINDCODE, MAINCHANNELID, MAINDESCRIPTIONLANGUAGECODE,
>>>> MAINTITLELANGUAGECODE, OVERLAYID, SELECTEDTHUMBNAILID) VALUES
>>>> (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
>>>> [params=(int) 74, (int) 0, (null) null, (null) null, (null) null,
>>>> (null) null, (null) null, (null) null, (int) 0, (null) null, (null)
>>>> null, (null) null, (null) null, (int) 3, (null) null, (null) null,
>>>> (null) null, (null) null, (null) null]
>>>> [junit-coverage] 8006 pu TRACE [main] openjpa.jdbc.SQL - <t
>>>> 9777317, conn 7891417> [2 ms] spent
>>>> [junit-coverage] ###### 3 I'm a class com.joost.model.show.Show
>>>> [junit-coverage] ###### 4 I'm a class com.joost.model.show.Show
>>>>
>>>> The code after the ###### 2 message is a getId(), and that triggers
>>>> the write to the db. You can see that we write to both
>>>> InventoryItem (the base class) and then VideoShow (java class Show
>>>> maps to the VideoShow table... public class Show extends
>>>> InventoryItem)
>>>>
>>>> However, for the case of "b" within "a", which is a ChannelItem
>>>> within a Channel (both of which extend InventoryItem) I get :
>>>>
>>>> [junit-coverage] ###### 1 I'm a class
>>>> com.joost.model.channel.Channel
>>>> [junit-coverage] ###### 2 I'm a class
>>>> com.joost.model.channel.Channel
>>>> [junit-coverage] ###### 1 I'm a class com.joost.model.ChannelItem
>>>> [junit-coverage] ###### 2 I'm a class com.joost.model.ChannelItem
>>>> [junit-coverage] Nov 15, 2007 4:51:04 PM
>>>> org.springframework.test.AbstractTransactionalSpringContextTests
>>>> endTransaction
>>>> [junit-coverage] INFO: Rolled back transaction after test execution
>>>> [junit-coverage] ------------- ---------------- ---------------
>>>> <EXCEPTION>
>>>>
>>>> so the getId() for the Channel ("a") called after the #### 2
>>>> message triggers the @PostPersist for the ChannelItem ("b") which
>>>> has a reference to the id for Channel. I think that therefore I
>>>> can conclude that what I'm doing is illegal according to the spec
>>>>
>>>> 3.5.2 : It isimplementation-dependent as to whether callback
>>>> methods are invoked before or after the cascading of the lifecycle
>>>> events to related entities. Applications should not depend on this
>>>> ordering.
>>>>
>>>> and therefore if that's true, I'm sorry for wasting your time :)
>>>>
>>>> Anyone have a clue how I can get out of this mess?
>>>>
>>>> geir
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>>
>>>>>
>>>>>>
>>>>>> b) what is the identity definition on b?
>>>>>> c) if b is using auto-assigned GeneratedValue or its id is being
>>>>>> set by
>>>>>> application?
>>>>>>
>>>>>> -----Original Message-----
>>>>>> From: Geir Magnusson Jr. [mailto:geir@pobox.com]
>>>>>> Sent: Thursday, November 15, 2007 11:10 AM
>>>>>> To: dev@openjpa.apache.org
>>>>>> Subject: @PostPersist woes
>>>>>>
>>>>>> Woe is me :)
>>>>>>
>>>>>> I'm using @PostPersist to create some kind of machine-generated
>>>>>> data for
>>>>>> entities on insert, and I'm running into the following problem
>>>>>> when an
>>>>>> entity for which I called persist() has in it a new, unmanaged
>>>>>> entity.
>>>>>>
>>>>>> [junit-coverage] Caused by: <openjpa-1.0.0-r420667:568756 fatal
>>>>>> user
>>>>>> error> org.apache.openjpa.util.InvalidStateException: Detected
>>>>>> reentrant flush. Make sure your flush-time instance callback
>>>>>> methods or
>>>>>> event listeners do not invoke any operations that require the in-
>>>>>> progress flush to complete.
>>>>>> [junit-coverage] at
>>>>>> org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:
>>>>>> 1840)
>>>>>> [junit-coverage] at
>>>>>> org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:1615)
>>>>>> [junit-coverage] at
>>>>>> org
>>>>>> .apache
>>>>>> .openjpa
>>>>>> .kernel.StateManagerImpl.assignObjectId(StateManagerImpl.java:
>>>>>> 505)
>>>>>> [junit-coverage] at
>>>>>> org
>>>>>> .apache
>>>>>> .openjpa
>>>>>> .kernel.StateManagerImpl.assignField(StateManagerImpl.java:590)
>>>>>> [junit-coverage] at
>>>>>> org
>>>>>> .apache
>>>>>> .openjpa
>>>>>> .kernel.StateManagerImpl.beforeAccessField(StateManagerImpl.java:
>>>>>> 1451)
>>>>>> [junit-coverage] at
>>>>>> org
>>>>>> .apache
>>>>>> .openjpa
>>>>>> .kernel.StateManagerImpl.accessingField(StateManagerImpl.java:
>>>>>> 1434)
>>>>>> [junit-coverage] at
>>>>>> com.joost.model.InventoryItem.getId(InventoryItem.java)
>>>>>> [junit-coverage] at
>>>>>> com
>>>>>> .joost.model.InventoryItem.initPublicIdIfNull(InventoryItem.java:
>>>>>> 331)
>>>>>>
>>>>>>
>>>>>> in InventoryItem, getId is the PK, and my read of the spec says
>>>>>> that I
>>>>>> am guaranteed to have it in @PostPersist.
>>>>>>
>>>>>> Bug? me doing something wrong?
>>>>>>
>>>>>> geir
>>>>>>
>>>>>>
>>>>>> Notice: This email message, together with any attachments, may
>>>>>> contain information of BEA Systems, Inc., its subsidiaries
>>>>>> and affiliated entities, that may be confidential,
>>>>>> proprietary, copyrighted and/or legally privileged, and is
>>>>>> intended solely for the use of the individual or entity named in
>>>>>> this message. If you are not the intended recipient, and have
>>>>>> received this message in error, please immediately return this by
>>>>>> email and then delete it.
>>>>>
>>>>
>>>
>>> Craig Russell
>>> Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
>>> 408 276-5638 mailto:Craig.Russell@sun.com
>>> P.S. A good JDO? O, Gasp!
>>>
>>
>>
>
>
>
> --
> Patrick Linskey
> 202 669 5907
Re: @PostPersist woes
Posted by Patrick Linskey <pl...@gmail.com>.
I think that there was a bit more to it... I think that you were also
trying to do something that required getting the OID during a
@PostPersist, right?
-Patrick
On Nov 17, 2007 12:26 PM, Geir Magnusson Jr. <ge...@pobox.com> wrote:
>
> On Nov 16, 2007, at 3:00 PM, Craig L Russell wrote:
>
> > Hi Geir,
> >
> > It still isn't clear to me what you are trying to accomplish. Would
> > it be possible for you to describe what the goal is? (I might have
> > missed the key idea in earlier posts...)
> >
>
> Persist an object graph in which object A that has a auto-gen PK and a
> reference to object B, such that object B has a PK and a reference to
> object A via a FK in table B.
>
> I found a workaround for now. I need to see if Hibernate can do
> this. I think it can. I realize that depending on that isn't
> portable, but it sure was convenient.
>
> geir
>
>
>
> > Craig
> >
> > On Nov 15, 2007, at 1:59 PM, Geir Magnusson Jr. wrote:
> >
> >>
> >> On Nov 15, 2007, at 4:41 PM, Geir Magnusson Jr. wrote:
> >>
> >>>
> >>> On Nov 15, 2007, at 4:34 PM, Pinaki Poddar wrote:
> >>>
> >>>>> persist() has in it a new, unmanaged entity.
> >>>>
> >>>> a) If persist(a) is failing on b, what is the cascade type
> >>>> specified on
> >>>> relation a.b?
> >>>
> >>> I'm not actually sure that it's failing on b. I guess I can try to
> >>> figure that out. I just know that when I change things so that I
> >>> have an unmanaged b, it fails.
> >>
> >> So I put some printlns in my @PostPersist routine, and I see that
> >> for something w/o the reference to an unmanaged entity, I get a
> >> sequence like this :
> >>
> >> [junit-coverage] ###### 1 I'm a class com.joost.model.show.Show
> >> [junit-coverage] ###### 2 I'm a class com.joost.model.show.Show
> >> [junit-coverage] 7996 pu TRACE [main] openjpa.jdbc.SQL - <t
> >> 9777317, conn 7891417> executing prepstmnt 9148991 INSERT INTO
> >> APP.INVENTORYITEM (CHANGENUMBER, COID, CREATIONDATE, DELETED,
> >> FIRSTPUBLICATIONDATE, LASTMODIFICATIONDATE, LATESTPUBLICATIONDATE,
> >> NAME, OKTOPUBLISH, PUBLICID, PUBLISHED, UUID, ITEMTYPE, DAMID,
> >> OWNERID) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
> >> [params=(null) null, (null) null, (Timestamp) 2007-11-15
> >> 16:51:04.42, (int) 0, (null) null, (Timestamp) 2007-11-15
> >> 16:51:04.42, (null) null, (String) a, (int) 0, (null) null, (int)
> >> 0, (String) 007ddeca-edff-4657-927f-ce77205c28ef, (String)
> >> VideoShow, (int) 10, (int) 10]
> >> [junit-coverage] 7997 pu TRACE [main] openjpa.jdbc.SQL - <t
> >> 9777317, conn 7891417> [1 ms] spent
> >> [junit-coverage] 7997 pu TRACE [main] openjpa.jdbc.SQL - <t
> >> 9777317, conn 7891417> executing prepstmnt 13415937
> >> VALUES(IDENTITY_VAL_LOCAL())
> >> [junit-coverage] 7997 pu TRACE [main] openjpa.jdbc.SQL - <t
> >> 9777317, conn 7891417> [0 ms] spent
> >> [junit-coverage] 8004 pu TRACE [main] openjpa.jdbc.SQL - <t
> >> 9777317, conn 7891417> executing prepstmnt 6406303 INSERT INTO
> >> APP.VIDEOSHOW (ID, ADSFREE, CODURATION, COFILENAME,
> >> MAINDESCRIPTION, MAINTITLE, MINAGE, PRODUCTIONYEARS, ISPROMOTIONAL,
> >> RIGHTS, VALIDFROM, VALIDTO, ADVERTISINGSHOWINFOID,
> >> GEORIGHTSKINDCODE, MAINCHANNELID, MAINDESCRIPTIONLANGUAGECODE,
> >> MAINTITLELANGUAGECODE, OVERLAYID, SELECTEDTHUMBNAILID) VALUES
> >> (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
> >> [params=(int) 74, (int) 0, (null) null, (null) null, (null) null,
> >> (null) null, (null) null, (null) null, (int) 0, (null) null, (null)
> >> null, (null) null, (null) null, (int) 3, (null) null, (null) null,
> >> (null) null, (null) null, (null) null]
> >> [junit-coverage] 8006 pu TRACE [main] openjpa.jdbc.SQL - <t
> >> 9777317, conn 7891417> [2 ms] spent
> >> [junit-coverage] ###### 3 I'm a class com.joost.model.show.Show
> >> [junit-coverage] ###### 4 I'm a class com.joost.model.show.Show
> >>
> >> The code after the ###### 2 message is a getId(), and that triggers
> >> the write to the db. You can see that we write to both
> >> InventoryItem (the base class) and then VideoShow (java class Show
> >> maps to the VideoShow table... public class Show extends
> >> InventoryItem)
> >>
> >> However, for the case of "b" within "a", which is a ChannelItem
> >> within a Channel (both of which extend InventoryItem) I get :
> >>
> >> [junit-coverage] ###### 1 I'm a class com.joost.model.channel.Channel
> >> [junit-coverage] ###### 2 I'm a class com.joost.model.channel.Channel
> >> [junit-coverage] ###### 1 I'm a class com.joost.model.ChannelItem
> >> [junit-coverage] ###### 2 I'm a class com.joost.model.ChannelItem
> >> [junit-coverage] Nov 15, 2007 4:51:04 PM
> >> org.springframework.test.AbstractTransactionalSpringContextTests
> >> endTransaction
> >> [junit-coverage] INFO: Rolled back transaction after test execution
> >> [junit-coverage] ------------- ---------------- ---------------
> >> <EXCEPTION>
> >>
> >> so the getId() for the Channel ("a") called after the #### 2
> >> message triggers the @PostPersist for the ChannelItem ("b") which
> >> has a reference to the id for Channel. I think that therefore I
> >> can conclude that what I'm doing is illegal according to the spec
> >>
> >> 3.5.2 : It isimplementation-dependent as to whether callback
> >> methods are invoked before or after the cascading of the lifecycle
> >> events to related entities. Applications should not depend on this
> >> ordering.
> >>
> >> and therefore if that's true, I'm sorry for wasting your time :)
> >>
> >> Anyone have a clue how I can get out of this mess?
> >>
> >> geir
> >>
> >>
> >>
> >>
> >>
> >>>
> >>>
> >>>>
> >>>> b) what is the identity definition on b?
> >>>> c) if b is using auto-assigned GeneratedValue or its id is being
> >>>> set by
> >>>> application?
> >>>>
> >>>> -----Original Message-----
> >>>> From: Geir Magnusson Jr. [mailto:geir@pobox.com]
> >>>> Sent: Thursday, November 15, 2007 11:10 AM
> >>>> To: dev@openjpa.apache.org
> >>>> Subject: @PostPersist woes
> >>>>
> >>>> Woe is me :)
> >>>>
> >>>> I'm using @PostPersist to create some kind of machine-generated
> >>>> data for
> >>>> entities on insert, and I'm running into the following problem
> >>>> when an
> >>>> entity for which I called persist() has in it a new, unmanaged
> >>>> entity.
> >>>>
> >>>> [junit-coverage] Caused by: <openjpa-1.0.0-r420667:568756 fatal
> >>>> user
> >>>> error> org.apache.openjpa.util.InvalidStateException: Detected
> >>>> reentrant flush. Make sure your flush-time instance callback
> >>>> methods or
> >>>> event listeners do not invoke any operations that require the in-
> >>>> progress flush to complete.
> >>>> [junit-coverage] at
> >>>> org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:
> >>>> 1840)
> >>>> [junit-coverage] at
> >>>> org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:1615)
> >>>> [junit-coverage] at
> >>>> org
> >>>> .apache
> >>>> .openjpa
> >>>> .kernel.StateManagerImpl.assignObjectId(StateManagerImpl.java:
> >>>> 505)
> >>>> [junit-coverage] at
> >>>> org
> >>>> .apache
> >>>> .openjpa
> >>>> .kernel.StateManagerImpl.assignField(StateManagerImpl.java:590)
> >>>> [junit-coverage] at
> >>>> org
> >>>> .apache
> >>>> .openjpa
> >>>> .kernel.StateManagerImpl.beforeAccessField(StateManagerImpl.java:
> >>>> 1451)
> >>>> [junit-coverage] at
> >>>> org
> >>>> .apache
> >>>> .openjpa
> >>>> .kernel.StateManagerImpl.accessingField(StateManagerImpl.java:
> >>>> 1434)
> >>>> [junit-coverage] at
> >>>> com.joost.model.InventoryItem.getId(InventoryItem.java)
> >>>> [junit-coverage] at
> >>>> com
> >>>> .joost.model.InventoryItem.initPublicIdIfNull(InventoryItem.java:
> >>>> 331)
> >>>>
> >>>>
> >>>> in InventoryItem, getId is the PK, and my read of the spec says
> >>>> that I
> >>>> am guaranteed to have it in @PostPersist.
> >>>>
> >>>> Bug? me doing something wrong?
> >>>>
> >>>> geir
> >>>>
> >>>>
> >>>> Notice: This email message, together with any attachments, may
> >>>> contain information of BEA Systems, Inc., its subsidiaries
> >>>> and affiliated entities, that may be confidential,
> >>>> proprietary, copyrighted and/or legally privileged, and is
> >>>> intended solely for the use of the individual or entity named in
> >>>> this message. If you are not the intended recipient, and have
> >>>> received this message in error, please immediately return this by
> >>>> email and then delete it.
> >>>
> >>
> >
> > Craig Russell
> > Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
> > 408 276-5638 mailto:Craig.Russell@sun.com
> > P.S. A good JDO? O, Gasp!
> >
>
>
--
Patrick Linskey
202 669 5907
Re: @PostPersist woes
Posted by "Geir Magnusson Jr." <ge...@pobox.com>.
On Nov 16, 2007, at 3:00 PM, Craig L Russell wrote:
> Hi Geir,
>
> It still isn't clear to me what you are trying to accomplish. Would
> it be possible for you to describe what the goal is? (I might have
> missed the key idea in earlier posts...)
>
Persist an object graph in which object A that has a auto-gen PK and a
reference to object B, such that object B has a PK and a reference to
object A via a FK in table B.
I found a workaround for now. I need to see if Hibernate can do
this. I think it can. I realize that depending on that isn't
portable, but it sure was convenient.
geir
> Craig
>
> On Nov 15, 2007, at 1:59 PM, Geir Magnusson Jr. wrote:
>
>>
>> On Nov 15, 2007, at 4:41 PM, Geir Magnusson Jr. wrote:
>>
>>>
>>> On Nov 15, 2007, at 4:34 PM, Pinaki Poddar wrote:
>>>
>>>>> persist() has in it a new, unmanaged entity.
>>>>
>>>> a) If persist(a) is failing on b, what is the cascade type
>>>> specified on
>>>> relation a.b?
>>>
>>> I'm not actually sure that it's failing on b. I guess I can try to
>>> figure that out. I just know that when I change things so that I
>>> have an unmanaged b, it fails.
>>
>> So I put some printlns in my @PostPersist routine, and I see that
>> for something w/o the reference to an unmanaged entity, I get a
>> sequence like this :
>>
>> [junit-coverage] ###### 1 I'm a class com.joost.model.show.Show
>> [junit-coverage] ###### 2 I'm a class com.joost.model.show.Show
>> [junit-coverage] 7996 pu TRACE [main] openjpa.jdbc.SQL - <t
>> 9777317, conn 7891417> executing prepstmnt 9148991 INSERT INTO
>> APP.INVENTORYITEM (CHANGENUMBER, COID, CREATIONDATE, DELETED,
>> FIRSTPUBLICATIONDATE, LASTMODIFICATIONDATE, LATESTPUBLICATIONDATE,
>> NAME, OKTOPUBLISH, PUBLICID, PUBLISHED, UUID, ITEMTYPE, DAMID,
>> OWNERID) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
>> [params=(null) null, (null) null, (Timestamp) 2007-11-15
>> 16:51:04.42, (int) 0, (null) null, (Timestamp) 2007-11-15
>> 16:51:04.42, (null) null, (String) a, (int) 0, (null) null, (int)
>> 0, (String) 007ddeca-edff-4657-927f-ce77205c28ef, (String)
>> VideoShow, (int) 10, (int) 10]
>> [junit-coverage] 7997 pu TRACE [main] openjpa.jdbc.SQL - <t
>> 9777317, conn 7891417> [1 ms] spent
>> [junit-coverage] 7997 pu TRACE [main] openjpa.jdbc.SQL - <t
>> 9777317, conn 7891417> executing prepstmnt 13415937
>> VALUES(IDENTITY_VAL_LOCAL())
>> [junit-coverage] 7997 pu TRACE [main] openjpa.jdbc.SQL - <t
>> 9777317, conn 7891417> [0 ms] spent
>> [junit-coverage] 8004 pu TRACE [main] openjpa.jdbc.SQL - <t
>> 9777317, conn 7891417> executing prepstmnt 6406303 INSERT INTO
>> APP.VIDEOSHOW (ID, ADSFREE, CODURATION, COFILENAME,
>> MAINDESCRIPTION, MAINTITLE, MINAGE, PRODUCTIONYEARS, ISPROMOTIONAL,
>> RIGHTS, VALIDFROM, VALIDTO, ADVERTISINGSHOWINFOID,
>> GEORIGHTSKINDCODE, MAINCHANNELID, MAINDESCRIPTIONLANGUAGECODE,
>> MAINTITLELANGUAGECODE, OVERLAYID, SELECTEDTHUMBNAILID) VALUES
>> (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
>> [params=(int) 74, (int) 0, (null) null, (null) null, (null) null,
>> (null) null, (null) null, (null) null, (int) 0, (null) null, (null)
>> null, (null) null, (null) null, (int) 3, (null) null, (null) null,
>> (null) null, (null) null, (null) null]
>> [junit-coverage] 8006 pu TRACE [main] openjpa.jdbc.SQL - <t
>> 9777317, conn 7891417> [2 ms] spent
>> [junit-coverage] ###### 3 I'm a class com.joost.model.show.Show
>> [junit-coverage] ###### 4 I'm a class com.joost.model.show.Show
>>
>> The code after the ###### 2 message is a getId(), and that triggers
>> the write to the db. You can see that we write to both
>> InventoryItem (the base class) and then VideoShow (java class Show
>> maps to the VideoShow table... public class Show extends
>> InventoryItem)
>>
>> However, for the case of "b" within "a", which is a ChannelItem
>> within a Channel (both of which extend InventoryItem) I get :
>>
>> [junit-coverage] ###### 1 I'm a class com.joost.model.channel.Channel
>> [junit-coverage] ###### 2 I'm a class com.joost.model.channel.Channel
>> [junit-coverage] ###### 1 I'm a class com.joost.model.ChannelItem
>> [junit-coverage] ###### 2 I'm a class com.joost.model.ChannelItem
>> [junit-coverage] Nov 15, 2007 4:51:04 PM
>> org.springframework.test.AbstractTransactionalSpringContextTests
>> endTransaction
>> [junit-coverage] INFO: Rolled back transaction after test execution
>> [junit-coverage] ------------- ---------------- ---------------
>> <EXCEPTION>
>>
>> so the getId() for the Channel ("a") called after the #### 2
>> message triggers the @PostPersist for the ChannelItem ("b") which
>> has a reference to the id for Channel. I think that therefore I
>> can conclude that what I'm doing is illegal according to the spec
>>
>> 3.5.2 : It isimplementation-dependent as to whether callback
>> methods are invoked before or after the cascading of the lifecycle
>> events to related entities. Applications should not depend on this
>> ordering.
>>
>> and therefore if that's true, I'm sorry for wasting your time :)
>>
>> Anyone have a clue how I can get out of this mess?
>>
>> geir
>>
>>
>>
>>
>>
>>>
>>>
>>>>
>>>> b) what is the identity definition on b?
>>>> c) if b is using auto-assigned GeneratedValue or its id is being
>>>> set by
>>>> application?
>>>>
>>>> -----Original Message-----
>>>> From: Geir Magnusson Jr. [mailto:geir@pobox.com]
>>>> Sent: Thursday, November 15, 2007 11:10 AM
>>>> To: dev@openjpa.apache.org
>>>> Subject: @PostPersist woes
>>>>
>>>> Woe is me :)
>>>>
>>>> I'm using @PostPersist to create some kind of machine-generated
>>>> data for
>>>> entities on insert, and I'm running into the following problem
>>>> when an
>>>> entity for which I called persist() has in it a new, unmanaged
>>>> entity.
>>>>
>>>> [junit-coverage] Caused by: <openjpa-1.0.0-r420667:568756 fatal
>>>> user
>>>> error> org.apache.openjpa.util.InvalidStateException: Detected
>>>> reentrant flush. Make sure your flush-time instance callback
>>>> methods or
>>>> event listeners do not invoke any operations that require the in-
>>>> progress flush to complete.
>>>> [junit-coverage] at
>>>> org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:
>>>> 1840)
>>>> [junit-coverage] at
>>>> org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:1615)
>>>> [junit-coverage] at
>>>> org
>>>> .apache
>>>> .openjpa
>>>> .kernel.StateManagerImpl.assignObjectId(StateManagerImpl.java:
>>>> 505)
>>>> [junit-coverage] at
>>>> org
>>>> .apache
>>>> .openjpa
>>>> .kernel.StateManagerImpl.assignField(StateManagerImpl.java:590)
>>>> [junit-coverage] at
>>>> org
>>>> .apache
>>>> .openjpa
>>>> .kernel.StateManagerImpl.beforeAccessField(StateManagerImpl.java:
>>>> 1451)
>>>> [junit-coverage] at
>>>> org
>>>> .apache
>>>> .openjpa
>>>> .kernel.StateManagerImpl.accessingField(StateManagerImpl.java:
>>>> 1434)
>>>> [junit-coverage] at
>>>> com.joost.model.InventoryItem.getId(InventoryItem.java)
>>>> [junit-coverage] at
>>>> com
>>>> .joost.model.InventoryItem.initPublicIdIfNull(InventoryItem.java:
>>>> 331)
>>>>
>>>>
>>>> in InventoryItem, getId is the PK, and my read of the spec says
>>>> that I
>>>> am guaranteed to have it in @PostPersist.
>>>>
>>>> Bug? me doing something wrong?
>>>>
>>>> geir
>>>>
>>>>
>>>> Notice: This email message, together with any attachments, may
>>>> contain information of BEA Systems, Inc., its subsidiaries
>>>> and affiliated entities, that may be confidential,
>>>> proprietary, copyrighted and/or legally privileged, and is
>>>> intended solely for the use of the individual or entity named in
>>>> this message. If you are not the intended recipient, and have
>>>> received this message in error, please immediately return this by
>>>> email and then delete it.
>>>
>>
>
> Craig Russell
> Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
> 408 276-5638 mailto:Craig.Russell@sun.com
> P.S. A good JDO? O, Gasp!
>
Re: @PostPersist woes
Posted by Craig L Russell <Cr...@Sun.COM>.
Hi Geir,
It still isn't clear to me what you are trying to accomplish. Would
it be possible for you to describe what the goal is? (I might have
missed the key idea in earlier posts...)
Craig
On Nov 15, 2007, at 1:59 PM, Geir Magnusson Jr. wrote:
>
> On Nov 15, 2007, at 4:41 PM, Geir Magnusson Jr. wrote:
>
>>
>> On Nov 15, 2007, at 4:34 PM, Pinaki Poddar wrote:
>>
>>>> persist() has in it a new, unmanaged entity.
>>>
>>> a) If persist(a) is failing on b, what is the cascade type
>>> specified on
>>> relation a.b?
>>
>> I'm not actually sure that it's failing on b. I guess I can try to
>> figure that out. I just know that when I change things so that I
>> have an unmanaged b, it fails.
>
> So I put some printlns in my @PostPersist routine, and I see that
> for something w/o the reference to an unmanaged entity, I get a
> sequence like this :
>
> [junit-coverage] ###### 1 I'm a class com.joost.model.show.Show
> [junit-coverage] ###### 2 I'm a class com.joost.model.show.Show
> [junit-coverage] 7996 pu TRACE [main] openjpa.jdbc.SQL - <t
> 9777317, conn 7891417> executing prepstmnt 9148991 INSERT INTO
> APP.INVENTORYITEM (CHANGENUMBER, COID, CREATIONDATE, DELETED,
> FIRSTPUBLICATIONDATE, LASTMODIFICATIONDATE, LATESTPUBLICATIONDATE,
> NAME, OKTOPUBLISH, PUBLICID, PUBLISHED, UUID, ITEMTYPE, DAMID,
> OWNERID) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
> [params=(null) null, (null) null, (Timestamp) 2007-11-15
> 16:51:04.42, (int) 0, (null) null, (Timestamp) 2007-11-15
> 16:51:04.42, (null) null, (String) a, (int) 0, (null) null, (int)
> 0, (String) 007ddeca-edff-4657-927f-ce77205c28ef, (String)
> VideoShow, (int) 10, (int) 10]
> [junit-coverage] 7997 pu TRACE [main] openjpa.jdbc.SQL - <t
> 9777317, conn 7891417> [1 ms] spent
> [junit-coverage] 7997 pu TRACE [main] openjpa.jdbc.SQL - <t
> 9777317, conn 7891417> executing prepstmnt 13415937 VALUES
> (IDENTITY_VAL_LOCAL())
> [junit-coverage] 7997 pu TRACE [main] openjpa.jdbc.SQL - <t
> 9777317, conn 7891417> [0 ms] spent
> [junit-coverage] 8004 pu TRACE [main] openjpa.jdbc.SQL - <t
> 9777317, conn 7891417> executing prepstmnt 6406303 INSERT INTO
> APP.VIDEOSHOW (ID, ADSFREE, CODURATION, COFILENAME,
> MAINDESCRIPTION, MAINTITLE, MINAGE, PRODUCTIONYEARS, ISPROMOTIONAL,
> RIGHTS, VALIDFROM, VALIDTO, ADVERTISINGSHOWINFOID,
> GEORIGHTSKINDCODE, MAINCHANNELID, MAINDESCRIPTIONLANGUAGECODE,
> MAINTITLELANGUAGECODE, OVERLAYID, SELECTEDTHUMBNAILID) VALUES
> (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) [params=
> (int) 74, (int) 0, (null) null, (null) null, (null) null, (null)
> null, (null) null, (null) null, (int) 0, (null) null, (null) null,
> (null) null, (null) null, (int) 3, (null) null, (null) null, (null)
> null, (null) null, (null) null]
> [junit-coverage] 8006 pu TRACE [main] openjpa.jdbc.SQL - <t
> 9777317, conn 7891417> [2 ms] spent
> [junit-coverage] ###### 3 I'm a class com.joost.model.show.Show
> [junit-coverage] ###### 4 I'm a class com.joost.model.show.Show
>
> The code after the ###### 2 message is a getId(), and that triggers
> the write to the db. You can see that we write to both
> InventoryItem (the base class) and then VideoShow (java class Show
> maps to the VideoShow table... public class Show extends
> InventoryItem)
>
> However, for the case of "b" within "a", which is a ChannelItem
> within a Channel (both of which extend InventoryItem) I get :
>
> [junit-coverage] ###### 1 I'm a class com.joost.model.channel.Channel
> [junit-coverage] ###### 2 I'm a class com.joost.model.channel.Channel
> [junit-coverage] ###### 1 I'm a class com.joost.model.ChannelItem
> [junit-coverage] ###### 2 I'm a class com.joost.model.ChannelItem
> [junit-coverage] Nov 15, 2007 4:51:04 PM
> org.springframework.test.AbstractTransactionalSpringContextTests
> endTransaction
> [junit-coverage] INFO: Rolled back transaction after test execution
> [junit-coverage] ------------- ---------------- ---------------
> <EXCEPTION>
>
> so the getId() for the Channel ("a") called after the #### 2
> message triggers the @PostPersist for the ChannelItem ("b") which
> has a reference to the id for Channel. I think that therefore I
> can conclude that what I'm doing is illegal according to the spec
>
> 3.5.2 : It isimplementation-dependent as to whether callback
> methods are invoked before or after the cascading of the lifecycle
> events to related entities. Applications should not depend on this
> ordering.
>
> and therefore if that's true, I'm sorry for wasting your time :)
>
> Anyone have a clue how I can get out of this mess?
>
> geir
>
>
>
>
>
>>
>>
>>>
>>> b) what is the identity definition on b?
>>> c) if b is using auto-assigned GeneratedValue or its id is being
>>> set by
>>> application?
>>>
>>> -----Original Message-----
>>> From: Geir Magnusson Jr. [mailto:geir@pobox.com]
>>> Sent: Thursday, November 15, 2007 11:10 AM
>>> To: dev@openjpa.apache.org
>>> Subject: @PostPersist woes
>>>
>>> Woe is me :)
>>>
>>> I'm using @PostPersist to create some kind of machine-generated
>>> data for
>>> entities on insert, and I'm running into the following problem
>>> when an
>>> entity for which I called persist() has in it a new, unmanaged
>>> entity.
>>>
>>> [junit-coverage] Caused by: <openjpa-1.0.0-r420667:568756 fatal user
>>> error> org.apache.openjpa.util.InvalidStateException: Detected
>>> reentrant flush. Make sure your flush-time instance callback
>>> methods or
>>> event listeners do not invoke any operations that require the in-
>>> progress flush to complete.
>>> [junit-coverage] at
>>> org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:1840)
>>> [junit-coverage] at
>>> org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:1615)
>>> [junit-coverage] at
>>> org
>>> .apache
>>> .openjpa.kernel.StateManagerImpl.assignObjectId
>>> (StateManagerImpl.java:
>>> 505)
>>> [junit-coverage] at
>>> org
>>> .apache
>>> .openjpa.kernel.StateManagerImpl.assignField
>>> (StateManagerImpl.java:590)
>>> [junit-coverage] at
>>> org
>>> .apache
>>> .openjpa
>>> .kernel.StateManagerImpl.beforeAccessField(StateManagerImpl.java:
>>> 1451)
>>> [junit-coverage] at
>>> org
>>> .apache
>>> .openjpa.kernel.StateManagerImpl.accessingField
>>> (StateManagerImpl.java:
>>> 1434)
>>> [junit-coverage] at
>>> com.joost.model.InventoryItem.getId(InventoryItem.java)
>>> [junit-coverage] at
>>> com.joost.model.InventoryItem.initPublicIdIfNull
>>> (InventoryItem.java:331)
>>>
>>>
>>> in InventoryItem, getId is the PK, and my read of the spec says
>>> that I
>>> am guaranteed to have it in @PostPersist.
>>>
>>> Bug? me doing something wrong?
>>>
>>> geir
>>>
>>>
>>> Notice: This email message, together with any attachments, may
>>> contain information of BEA Systems, Inc., its subsidiaries
>>> and affiliated entities, that may be confidential,
>>> proprietary, copyrighted and/or legally privileged, and is
>>> intended solely for the use of the individual or entity named in
>>> this message. If you are not the intended recipient, and have
>>> received this message in error, please immediately return this by
>>> email and then delete it.
>>
>
Craig Russell
Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
408 276-5638 mailto:Craig.Russell@sun.com
P.S. A good JDO? O, Gasp!
Re: @PostPersist woes
Posted by "Geir Magnusson Jr." <ge...@pobox.com>.
On Nov 15, 2007, at 4:41 PM, Geir Magnusson Jr. wrote:
>
> On Nov 15, 2007, at 4:34 PM, Pinaki Poddar wrote:
>
>>> persist() has in it a new, unmanaged entity.
>>
>> a) If persist(a) is failing on b, what is the cascade type
>> specified on
>> relation a.b?
>
> I'm not actually sure that it's failing on b. I guess I can try to
> figure that out. I just know that when I change things so that I
> have an unmanaged b, it fails.
So I put some printlns in my @PostPersist routine, and I see that for
something w/o the reference to an unmanaged entity, I get a sequence
like this :
[junit-coverage] ###### 1 I'm a class com.joost.model.show.Show
[junit-coverage] ###### 2 I'm a class com.joost.model.show.Show
[junit-coverage] 7996 pu TRACE [main] openjpa.jdbc.SQL - <t
9777317, conn 7891417> executing prepstmnt 9148991 INSERT INTO
APP.INVENTORYITEM (CHANGENUMBER, COID, CREATIONDATE, DELETED,
FIRSTPUBLICATIONDATE, LASTMODIFICATIONDATE, LATESTPUBLICATIONDATE,
NAME, OKTOPUBLISH, PUBLICID, PUBLISHED, UUID, ITEMTYPE, DAMID,
OWNERID) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
[params=(null) null, (null) null, (Timestamp) 2007-11-15 16:51:04.42,
(int) 0, (null) null, (Timestamp) 2007-11-15 16:51:04.42, (null) null,
(String) a, (int) 0, (null) null, (int) 0, (String) 007ddeca-
edff-4657-927f-ce77205c28ef, (String) VideoShow, (int) 10, (int) 10]
[junit-coverage] 7997 pu TRACE [main] openjpa.jdbc.SQL - <t
9777317, conn 7891417> [1 ms] spent
[junit-coverage] 7997 pu TRACE [main] openjpa.jdbc.SQL - <t
9777317, conn 7891417> executing prepstmnt 13415937
VALUES(IDENTITY_VAL_LOCAL())
[junit-coverage] 7997 pu TRACE [main] openjpa.jdbc.SQL - <t
9777317, conn 7891417> [0 ms] spent
[junit-coverage] 8004 pu TRACE [main] openjpa.jdbc.SQL - <t
9777317, conn 7891417> executing prepstmnt 6406303 INSERT INTO
APP.VIDEOSHOW (ID, ADSFREE, CODURATION, COFILENAME, MAINDESCRIPTION,
MAINTITLE, MINAGE, PRODUCTIONYEARS, ISPROMOTIONAL, RIGHTS, VALIDFROM,
VALIDTO, ADVERTISINGSHOWINFOID, GEORIGHTSKINDCODE, MAINCHANNELID,
MAINDESCRIPTIONLANGUAGECODE, MAINTITLELANGUAGECODE, OVERLAYID,
SELECTEDTHUMBNAILID) VALUES
(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
[params=(int) 74, (int) 0, (null) null, (null) null, (null) null,
(null) null, (null) null, (null) null, (int) 0, (null) null, (null)
null, (null) null, (null) null, (int) 3, (null) null, (null) null,
(null) null, (null) null, (null) null]
[junit-coverage] 8006 pu TRACE [main] openjpa.jdbc.SQL - <t
9777317, conn 7891417> [2 ms] spent
[junit-coverage] ###### 3 I'm a class com.joost.model.show.Show
[junit-coverage] ###### 4 I'm a class com.joost.model.show.Show
The code after the ###### 2 message is a getId(), and that triggers
the write to the db. You can see that we write to both InventoryItem
(the base class) and then VideoShow (java class Show maps to the
VideoShow table... public class Show extends InventoryItem)
However, for the case of "b" within "a", which is a ChannelItem within
a Channel (both of which extend InventoryItem) I get :
[junit-coverage] ###### 1 I'm a class com.joost.model.channel.Channel
[junit-coverage] ###### 2 I'm a class com.joost.model.channel.Channel
[junit-coverage] ###### 1 I'm a class com.joost.model.ChannelItem
[junit-coverage] ###### 2 I'm a class com.joost.model.ChannelItem
[junit-coverage] Nov 15, 2007 4:51:04 PM
org.springframework.test.AbstractTransactionalSpringContextTests
endTransaction
[junit-coverage] INFO: Rolled back transaction after test execution
[junit-coverage] ------------- ---------------- ---------------
<EXCEPTION>
so the getId() for the Channel ("a") called after the #### 2 message
triggers the @PostPersist for the ChannelItem ("b") which has a
reference to the id for Channel. I think that therefore I can
conclude that what I'm doing is illegal according to the spec
3.5.2 : It isimplementation-dependent as to whether callback
methods are invoked before or after the cascading of the lifecycle
events to related entities. Applications should not depend on this
ordering.
and therefore if that's true, I'm sorry for wasting your time :)
Anyone have a clue how I can get out of this mess?
geir
>
>
>>
>> b) what is the identity definition on b?
>> c) if b is using auto-assigned GeneratedValue or its id is being
>> set by
>> application?
>>
>> -----Original Message-----
>> From: Geir Magnusson Jr. [mailto:geir@pobox.com]
>> Sent: Thursday, November 15, 2007 11:10 AM
>> To: dev@openjpa.apache.org
>> Subject: @PostPersist woes
>>
>> Woe is me :)
>>
>> I'm using @PostPersist to create some kind of machine-generated
>> data for
>> entities on insert, and I'm running into the following problem when
>> an
>> entity for which I called persist() has in it a new, unmanaged
>> entity.
>>
>> [junit-coverage] Caused by: <openjpa-1.0.0-r420667:568756 fatal user
>> error> org.apache.openjpa.util.InvalidStateException: Detected
>> reentrant flush. Make sure your flush-time instance callback
>> methods or
>> event listeners do not invoke any operations that require the in-
>> progress flush to complete.
>> [junit-coverage] at
>> org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:1840)
>> [junit-coverage] at
>> org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:1615)
>> [junit-coverage] at
>> org
>> .apache
>> .openjpa
>> .kernel.StateManagerImpl.assignObjectId(StateManagerImpl.java:
>> 505)
>> [junit-coverage] at
>> org
>> .apache
>> .openjpa.kernel.StateManagerImpl.assignField(StateManagerImpl.java:
>> 590)
>> [junit-coverage] at
>> org
>> .apache
>> .openjpa
>> .kernel.StateManagerImpl.beforeAccessField(StateManagerImpl.java:
>> 1451)
>> [junit-coverage] at
>> org
>> .apache
>> .openjpa
>> .kernel.StateManagerImpl.accessingField(StateManagerImpl.java:
>> 1434)
>> [junit-coverage] at
>> com.joost.model.InventoryItem.getId(InventoryItem.java)
>> [junit-coverage] at
>> com.joost.model.InventoryItem.initPublicIdIfNull(InventoryItem.java:
>> 331)
>>
>>
>> in InventoryItem, getId is the PK, and my read of the spec says
>> that I
>> am guaranteed to have it in @PostPersist.
>>
>> Bug? me doing something wrong?
>>
>> geir
>>
>>
>> Notice: This email message, together with any attachments, may
>> contain information of BEA Systems, Inc., its subsidiaries
>> and affiliated entities, that may be confidential, proprietary,
>> copyrighted and/or legally privileged, and is intended solely for
>> the use of the individual or entity named in this message. If you
>> are not the intended recipient, and have received this message in
>> error, please immediately return this by email and then delete it.
>
Re: @PostPersist woes
Posted by "Geir Magnusson Jr." <ge...@pobox.com>.
On Nov 15, 2007, at 4:34 PM, Pinaki Poddar wrote:
>> persist() has in it a new, unmanaged entity.
>
> a) If persist(a) is failing on b, what is the cascade type specified
> on
> relation a.b?
I'm not actually sure that it's failing on b. I guess I can try to
figure that out. I just know that when I change things so that I
have an unmanaged b, it fails.
>
> b) what is the identity definition on b?
> c) if b is using auto-assigned GeneratedValue or its id is being set
> by
> application?
>
> -----Original Message-----
> From: Geir Magnusson Jr. [mailto:geir@pobox.com]
> Sent: Thursday, November 15, 2007 11:10 AM
> To: dev@openjpa.apache.org
> Subject: @PostPersist woes
>
> Woe is me :)
>
> I'm using @PostPersist to create some kind of machine-generated data
> for
> entities on insert, and I'm running into the following problem when an
> entity for which I called persist() has in it a new, unmanaged entity.
>
> [junit-coverage] Caused by: <openjpa-1.0.0-r420667:568756 fatal user
> error> org.apache.openjpa.util.InvalidStateException: Detected
> reentrant flush. Make sure your flush-time instance callback
> methods or
> event listeners do not invoke any operations that require the in-
> progress flush to complete.
> [junit-coverage] at
> org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:1840)
> [junit-coverage] at
> org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:1615)
> [junit-coverage] at
> org
> .apache
> .openjpa.kernel.StateManagerImpl.assignObjectId(StateManagerImpl.java:
> 505)
> [junit-coverage] at
> org
> .apache
> .openjpa.kernel.StateManagerImpl.assignField(StateManagerImpl.java:
> 590)
> [junit-coverage] at
> org
> .apache
> .openjpa
> .kernel.StateManagerImpl.beforeAccessField(StateManagerImpl.java:1451)
> [junit-coverage] at
> org
> .apache
> .openjpa.kernel.StateManagerImpl.accessingField(StateManagerImpl.java:
> 1434)
> [junit-coverage] at
> com.joost.model.InventoryItem.getId(InventoryItem.java)
> [junit-coverage] at
> com.joost.model.InventoryItem.initPublicIdIfNull(InventoryItem.java:
> 331)
>
>
> in InventoryItem, getId is the PK, and my read of the spec says that I
> am guaranteed to have it in @PostPersist.
>
> Bug? me doing something wrong?
>
> geir
>
>
> Notice: This email message, together with any attachments, may
> contain information of BEA Systems, Inc., its subsidiaries and
> affiliated entities, that may be confidential, proprietary,
> copyrighted and/or legally privileged, and is intended solely for
> the use of the individual or entity named in this message. If you
> are not the intended recipient, and have received this message in
> error, please immediately return this by email and then delete it.
RE: @PostPersist woes
Posted by Pinaki Poddar <pp...@bea.com>.
> persist() has in it a new, unmanaged entity.
a) If persist(a) is failing on b, what is the cascade type specified on
relation a.b?
b) what is the identity definition on b?
c) if b is using auto-assigned GeneratedValue or its id is being set by
application?
-----Original Message-----
From: Geir Magnusson Jr. [mailto:geir@pobox.com]
Sent: Thursday, November 15, 2007 11:10 AM
To: dev@openjpa.apache.org
Subject: @PostPersist woes
Woe is me :)
I'm using @PostPersist to create some kind of machine-generated data for
entities on insert, and I'm running into the following problem when an
entity for which I called persist() has in it a new, unmanaged entity.
[junit-coverage] Caused by: <openjpa-1.0.0-r420667:568756 fatal user
error> org.apache.openjpa.util.InvalidStateException: Detected
reentrant flush. Make sure your flush-time instance callback methods or
event listeners do not invoke any operations that require the in-
progress flush to complete.
[junit-coverage] at
org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:1840)
[junit-coverage] at
org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:1615)
[junit-coverage] at
org
.apache
.openjpa.kernel.StateManagerImpl.assignObjectId(StateManagerImpl.java:
505)
[junit-coverage] at
org
.apache
.openjpa.kernel.StateManagerImpl.assignField(StateManagerImpl.java:590)
[junit-coverage] at
org
.apache
.openjpa
.kernel.StateManagerImpl.beforeAccessField(StateManagerImpl.java:1451)
[junit-coverage] at
org
.apache
.openjpa.kernel.StateManagerImpl.accessingField(StateManagerImpl.java:
1434)
[junit-coverage] at
com.joost.model.InventoryItem.getId(InventoryItem.java)
[junit-coverage] at
com.joost.model.InventoryItem.initPublicIdIfNull(InventoryItem.java:331)
in InventoryItem, getId is the PK, and my read of the spec says that I
am guaranteed to have it in @PostPersist.
Bug? me doing something wrong?
geir
Notice: This email message, together with any attachments, may contain information of BEA Systems, Inc., its subsidiaries and affiliated entities, that may be confidential, proprietary, copyrighted and/or legally privileged, and is intended solely for the use of the individual or entity named in this message. If you are not the intended recipient, and have received this message in error, please immediately return this by email and then delete it.