Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] @PostLoad not called on a ReadAllQuery?

In EclipseLink the JPA postLoad event is translated into the native
EclipseLink events.  Currently it sets the EclipseLink events, postBuild
(called when a new object is built from the database), postRefresh (called
when an existing object is refreshed from the database), postClone (called
whenever EclipseLink clones an object, such as registering an object from
the shared cache into the EntityManager persistence context, but also when
merging back into the shared cache, and when copying a new object or merged
object).  So the postLoad on persist/merge is caused by the postClone, which
is odd, you may wish to log a bug for this as calling postLoad here does not
seem correct.

As for why postLoad is not called on your ReadAllQuery, I'm not sure.  Can
you include the code on how you execute the query.  Is the postLoad called
when executing JPA queries?

My guess is that the object is already in the shared cache, so when you
execute the query, you get the existing object from the shared cache, so it
is not loaded from the database, so no event.  Your query is probably
somehow read-only or using the ServerSession, so the object is not cloned. 
If you used a UnitOfWork, it would be cloned causing the event.

DeSilentio wrote:
> Also...
> I am using an non container managed persistent unit although using it with
> glassfish.
> I believe I am using eclipselink 1.0.2.
> Strangely it looks like the method marked as @PostLoad is being called
> when I persist/merge an object of this type.
> DeSilentio wrote:
>> Hi,
>> I'm performing a ReadAllQuery to retrieve a ScrollableCursor. I have a
>> method of the class I'm trying to retrieve that is annotated as
>> @PostLoad. However, this method does not appear to be called when I use
>> the ReadAllQuery. What is the appropriate way to make sure this method is
>> called after the query is performed?
>> Any help appreciated.

--- James Sutherland
 EclipseLink ,
Wiki: EclipseLink , TopLink 
Forums: TopLink , EclipseLink 
Book: Java Persistence 
View this message in context:
Sent from the EclipseLink - Users mailing list archive at

Back to the top