You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "Simon Droscher (JIRA)" <ji...@apache.org> on 2009/03/18 18:19:50 UTC

[jira] Updated: (OPENJPA-984) PostLoad and PostUpdate not called for objects with a bidirectional relationship

     [ https://issues.apache.org/jira/browse/OPENJPA-984?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Simon Droscher updated OPENJPA-984:
-----------------------------------

    Description: 
A method marked with @PostLoad or @PostUpdate on an object that is the toMany side of a bi-directional relationship does not get called when the other object is loaded or updated.

I can confirm that this problem was introduced by the changes done in [OPENJPA-744]. Looks like the StateManagerImpl.postLoad() method is not firing the event due to the bidirectional field not being flagged as loaded.

An example:

@Entity
public class Order {
  @OneToMany(cascade = CascadeType.ALL, mappedBy = "order", fetch = FetchType.EAGER)
  public List<Shipment> getShipments() {
    return shipments;
  }
}

@Entity
public class Shipment {
  @ManyToOne(fetch = FetchType.EAGER, cascade = { CascadeType.MERGE, CascadeType.REFRESH })
  public Order getOrder() {
    return order;
  }

  @PostLoad
  public void doSomethingAfterLoad() {
    // do something
  }
}

In the above example the doSomethingAfterLoad() never gets called when you load an Order. Without the changes done in [OPENJPA-744] it does.


  was:
A method marked with @PostLoad or @PostUpdate on an object that is the toMany side of a bi-directional relationship does not get called when the other object is loaded or updated.

I can confirm that this problem was introduced by the changes done in [OPENJPA-744]. Looks like the StateManagerImpl.postLoad() method is not firing the event due to the bidirectional field not being flagged as loaded.

An example:

{code}
@Entity
public class Order {
  @OneToMany(cascade = CascadeType.ALL, mappedBy = "order", fetch = FetchType.EAGER)
  public List<Shipment> getShipments() {
    return shipments;
  }
}

@Entity
public class Shipment {
  @ManyToOne(fetch = FetchType.EAGER, cascade = { CascadeType.MERGE, CascadeType.REFRESH })
  public Order getOrder() {
    return order;
  }

  @PostLoad
  public void doSomethingAfterLoad() {
    // do something
  }
}
{code}

In the above example the doSomethingAfterLoad() never gets called when you load an Order. Without the changes done in [OPENJPA-744] it does.



> PostLoad and PostUpdate not called for objects with a bidirectional relationship
> --------------------------------------------------------------------------------
>
>                 Key: OPENJPA-984
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-984
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jdbc
>    Affects Versions: 1.2.1, 1.3.0
>            Reporter: Simon Droscher
>
> A method marked with @PostLoad or @PostUpdate on an object that is the toMany side of a bi-directional relationship does not get called when the other object is loaded or updated.
> I can confirm that this problem was introduced by the changes done in [OPENJPA-744]. Looks like the StateManagerImpl.postLoad() method is not firing the event due to the bidirectional field not being flagged as loaded.
> An example:
> @Entity
> public class Order {
>   @OneToMany(cascade = CascadeType.ALL, mappedBy = "order", fetch = FetchType.EAGER)
>   public List<Shipment> getShipments() {
>     return shipments;
>   }
> }
> @Entity
> public class Shipment {
>   @ManyToOne(fetch = FetchType.EAGER, cascade = { CascadeType.MERGE, CascadeType.REFRESH })
>   public Order getOrder() {
>     return order;
>   }
>   @PostLoad
>   public void doSomethingAfterLoad() {
>     // do something
>   }
> }
> In the above example the doSomethingAfterLoad() never gets called when you load an Order. Without the changes done in [OPENJPA-744] it does.

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