openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rick Curtis <>
Subject Re: Callback before items are persisted
Date Fri, 06 Dec 2013 17:35:29 GMT
If you don't mind using implementation specific features, you could look
into using a transaction listener[1]?



On Fri, Dec 6, 2013 at 10:40 AM, Jim Talbut <> wrote:

> 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.

*Rick Curtis*

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message