Re: [eclipselink-users] Cache Characteristics of @ReadOnly Entities?
Thanks for the reply. Adding a REFRESH and REFRESH_CASCADE hints does fix
the staleness issue, but it opens up another can of worms. I have a fairly
deep, read-only object graph that gets traversed multiple times per
UnitOfWork. The graph can get changed by another process between
UnitsOfWork, which is where the staleness issue creeps in, and where my
refresh concerns come from.
I would have expected these two scenarios to take equivalent time:
1) Traverse an uncached graph gotten from an unhinted query (i.e.
accessing it for the first time in a session)
2) Travers a graph gotten from a cascaded REFRESH query
The problem is that scenario #2 takes orders of magnitude longer than
scenario #1. This doesn't make any sense to me, unless there's something
about those hints that disables an optimization like batch fetch?
An obvious follow-up question: is there a way to programmatically remove an
object from the session cache?
James Sutherland wrote:
> Read-only objects are meant to only exist in the shared cache. Using an
> isolated or not shared cache with read-only would be unusual. If you want
> the object registered in the unit of work, then just don't mark it as
> To refresh a read-only object execute a query for it using the
> "eclipselink.refresh"="true" query hint, or using the JPA 2.0 find() that
> takes query hint properties with the refresh.
> rscharer wrote:
>> Hey folks,
>> I've got a number of entities tagged as @ReadOnly, and I can't seem to
>> control when they refresh their state from the database, either manually
>> or through cache configuration. My ideal would be one of these two
>> 1) Configure the cache so the state of a @ReadOnly entity is preserved
>> for the duration of a single UnitOfWork.
>> 2) Be able to manually refresh the state of a @ReadOnly entity.
>> I've tried various ways to accomplish #1 (Even setting CacheType to NONE
>> as an experiment) and EclipseLink doesn't seem to care. The
>> documentation is sparse on the intersection of @Cache and @ReadOnly,
>> though, so hopefully I'm just missing something.
>> There isn't an obvious way to get at #2 either. @ReadOnly entities are
>> detached, so calling EntityManager.refresh() just causes an exception.
>> Anybody have any advice for me?
View this message in context: http://old.nabble.com/Cache-Characteristics-of-%40ReadOnly-Entities--tp27742994p27757407.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.