Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Query Cache in 2.4.1 Help
Query Cache in 2.4.1 Help [message #1044190] Thu, 18 April 2013 15:42 Go to next message
howard kelsey is currently offline howard kelseyFriend
Messages: 1
Registered: April 2013
Junior Member
We've just started using EclipseLink and I'm having an issue using the QueryCache.
I have a named query which I setup following the example at http://wiki.eclipse.org/EclipseLink/UserGuide/JPA/Basic_JPA_Development/Caching/Query_Cache

@NamedQuery(name = "CustomField.loadAll",
query = "select cf from CustomField cf",
hints = {
@QueryHint(name = QueryHints.QUERY_RESULTS_CACHE, value = HintValues.TRUE),
@QueryHint(name=QueryHints.QUERY_RESULTS_CACHE_SIZE, value="1")})

Now when the query is run the query cache is only updated if there are no results. I believe that this is caused by the fact that in ReadAllQuery if the results are empty then following is executed
this.temporaryCachedQueryResults = InvalidObject.instance();

If however there are results they are never cached because in org.eclipse.persistence.internal.descriptors.ObjectBuilder#buildObject
session.isUnitOfWork is true which means the cacheResult method on the query is never called.

So either it's a bug that the empty results are cached or that results are not, I believe the former.

Any help with this would be greatly appreciated.
Regards
Howard

Re: Query Cache in 2.4.1 Help [message #1047675 is a reply to message #1044190] Tue, 23 April 2013 14:04 Go to previous message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

How do you execute the query? Do you have changes made in your persistence context, or have you called flush() or executed a native SQL query?

The query results cannot be cached if you have potentially changed the data in a transaction. I assume this is what you have done.

I believe it is a bug that the empty results are being cached, if you are in an early transaction, they should not be cached.

You can execute your query at the start of the transaction before changing anything, or you can execute it as a read-only query.


James : Wiki : Book : Blog : Twitter
Previous Topic:One to One Relationship With Shared PK not Working at Execution time
Next Topic:How to use EclipseLink 2.4.1 in GlassFish 3.1.1?
Goto Forum:
  


Current Time: Thu Oct 10 20:34:26 GMT 2024

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

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

Back to the top