Hi Tobias,
The problem is that my entity doesn't have values set before persist is
called, the values are all set after persist.
But there isn't a callback that is called before the entity is actually
written to the database (when the transaction ends) which seems like a gap.
I would have expected that either PrePersist was called at that point,
or (given that having a callback when PrePersist is called is useful for
setting keys) that there would be a PreFlush callback later.
In the project I'm working on, for the entity I want the callbacks for,
it isn't a big problem to move the call to persist after everything in
the entity has been set, but other JPA projects that I have simply
couldn't do that.
Jim
On 06/12/2013 16:34, Meyer, Tobias wrote:
could you provide some same sample code?
If your entity has values set before persist is called, then I can't imagine
how they would disappear when the PrePersist callback method is invoked.
Example 3.5.3 in the JPA 2.0 spec shows that you should be able to access
persistent fields/properties of your entity in the context of a PrePersist
callback.