Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » readonly query and mix isolated and shared cache types(readonly query by entities with isolated caching doesn't use referenced entities in shared cache)
readonly query and mix isolated and shared cache types [message #1354802] Wed, 14 May 2014 12:34 Go to next message
Serge Poberezhnik is currently offline Serge PoberezhnikFriend
Messages: 2
Registered: May 2014
Junior Member
Hello!

I have two entities. One is highly volatile entity Event, references rarely changed entity EventType. So, for Event i use isolated cache type, and for EventType - shared cache.
Then i need to select large list of Events for read only purpose. Therefore READONLY query hint is used:
query.setHint(QueryHints.READ_ONLY, HintValues.TRUE);
Then, when JPQL query:
select e from Event e
executes repeatedly, i see in eclipselink log that reference to EventType resolves for selected Events each time with physical query from EventType table:
select * from EventType where typeCode = ?
Not just in first JPQL query executing, but each time. So shared cache for EventType entity not used for references resolving. This significant reduces overall JPQL query performance execution.

Such behavior begins after start using Glassfish 4.0. with corresponded eclipselink version 2.5.1. With version 2.5.0 and 2.4.0 this situation is reproduced too. In Glassfish 3.2 with eclipselink version 2.3.2 everything was fine - shared cache was used for resolving references from isolated caching enttities in readonly queries.

Is somebody stucks with such problem? What should i do to right configure entities and query?
Re: readonly query and mix isolated and shared cache types [message #1355157 is a reply to message #1354802] Wed, 14 May 2014 15:45 Go to previous messageGo to next message
Peter Nehrer is currently offline Peter NehrerFriend
Messages: 240
Registered: July 2009
Senior Member
FWIW... with 2.5.1 I'm finding that having so much as a single isolated
entity in the model basically negates shared cache as each session
that's set up is isolated and nothing is ever found in the "parent"
session (shared cache) as implied by documentation.

For the time being I'm leaving shared cache enabled on every entity but
annotate the few that should not be cached with alwaysRefresh=true,
disableHits=true. This seems to be doing the right thing.

On 5/14/14, 9:19 AM, Serge Poberezhnik wrote:
> Hello!
>
> I have two entities. One is highly volatile entity Event, references
> rarely changed entity EventType. So, for Event i use isolated cache
> type, and for EventType - shared cache.
> Then i need to select large list of Events for read only purpose.
> Therefore READONLY query hint is used:
> query.setHint(QueryHints.READ_ONLY, HintValues.TRUE); Then, when JPQL
> query: select e from Event e
> executes repeatedly, i see in eclipselink log that reference to
> EventType resolves for selected Events each time with physical query
> from EventType table:
> select * from EventType where typeCode = ?
> Not just in first JPQL query executing, but each time. So shared cache
> for EventType entity not used for references resolving. This significant
> reduces overall JPQL query performance execution.
> Such behavior begins after start using Glassfish 4.0. with corresponded
> eclipselink version 2.5.1. With version 2.5.0 and 2.4.0 this situation
> is reproduced too. In Glassfish 3.2 with eclipselink version 2.3.2
> everything was fine - shared cache was used for resolving references
> from isolated caching enttities in readonly queries.
>
> Is somebody stucks with such problem? What should i do to right
> configure entities and query?
Re: readonly query and mix isolated and shared cache types [message #1357079 is a reply to message #1355157] Thu, 15 May 2014 10:55 Go to previous message
Serge Poberezhnik is currently offline Serge PoberezhnikFriend
Messages: 2
Registered: May 2014
Junior Member
Thank for your reply, Peter
you wrote
For the time being I'm leaving shared cache enabled on every entity but
annotate the few that should not be cached with alwaysRefresh=true,
disableHits=true. This seems to be doing the right thing.

I tried to do this. Setting up alwaysRefresh=true, disableHits=true in entity cache options leads to appearing lots of additional physical queries to refresh each of selected rows, such as
select * from Event where eventId = ?
That essentially reduce query performance and not minimize memory usage for cache. I need to select huge amount of frequently changed data. It would be right to not cache this data at all. Otherwise, when shared cache for this entity is enabled, memory is ended soon and throwing java heap space error in a log.
When i set up shared cache size to 0, this equivalent to switching off the shared cache usage for referenced entities too. It began to selecting directly from database, ommiting cache repeatedly. Query becomes too slow.

Setting cache size to small value, say 10 doesn't effect and "java heap space" error is coming soon
Previous Topic:@Embeddable class containing type of its own
Next Topic:Prepersist ISSUE with merge(when creating a new entity).
Goto Forum:
  


Current Time: Fri Jul 03 08:08:51 GMT 2015

Powered by FUDForum. Page generated in 0.03304 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software