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:
{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.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.