Uploaded image for project: 'OpenJPA'
  1. OpenJPA
  2. OPENJPA-984

PostLoad and PostUpdate not called for objects with a bidirectional relationship

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.2.1, 1.3.0
    • None
    • jdbc
    • None

    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.

      Attachments

        Activity

          People

            Unassigned Unassigned
            sdroscher Simon Droscher
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: