openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Pinaki Poddar" <ppod...@bea.com>
Subject RE: @PostPersist woes
Date Thu, 15 Nov 2007 22:42:03 GMT
>
>
> 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.

Mime
View raw message