openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Fay Wang (JIRA)" <>
Subject [jira] Commented: (OPENJPA-1004) Derived Identity fails when parent id is auto-generated
Date Mon, 30 Mar 2009 23:35:51 GMT


Fay Wang commented on OPENJPA-1004:

The PCEnhancer generates pcCopyKeyFieldsToObjectId as following:

  public void pcCopyKeyFieldsToObjectId(Object paramObject)
    Object localObject;
    ChildId localChildId = (ChildId)((ObjectId)paramObject).getId(); =;
    Parent localParent = this.parent;
    if (localParent != null)
      localObject = ((PersistenceCapable)localParent).pcFetchObjectId();
    localChildId.parent = ((localObject != null) ? ((LongId)localObject).getId() : 0L);

Since the parent has generated key, its objectId is null during pre-flush stage, the parent.pcFetchObjectId
will throw the exception: 

<openjpa-1.2.1-r752877:753278 fatal user error> org.apache.openjpa.persistence.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.
    at org.apache.openjpa.kernel.BrokerImpl.flushSafe(
    at org.apache.openjpa.kernel.BrokerImpl.flush(
    at org.apache.openjpa.kernel.StateManagerImpl.assignObjectId(
    at org.apache.openjpa.kernel.StateManagerImpl.assignObjectId(
    at org.apache.openjpa.kernel.StateManagerImpl.fetchObjectId(

The proposed fix is to have PCEnhancer generate the following code when parent has generated

  public void pcCopyKeyFieldsToObjectId(Object paramObject)
    ChildId localChildId = (ChildId)((ObjectId)paramObject).getId(); =;
    localChildId.parent = 0L;

The test case then passed.

> Derived Identity fails when parent id is auto-generated
> -------------------------------------------------------
>                 Key: OPENJPA-1004
>                 URL:
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 1.2.2, 2.0.0
>            Reporter: Fay Wang

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message