Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » how to automatically refresh a cached namedquery after object insertion/deletion ?
how to automatically refresh a cached namedquery after object insertion/deletion ? [message #696990] Fri, 15 July 2011 09:21 Go to next message
Sebastian  is currently offline Sebastian Friend
Messages: 2
Registered: July 2011
Junior Member
Hi All,


I have a cached namedquery

@NamedQuery(name = "CoverholderAgreement.all",
        query = "SELECT c FROM CoverholderAgreement c",
        hints = {
            @QueryHint(name = QueryHints. QUERY_RESULTS_CACHE, value=HintValues.TRUE)
        })


which speed up my code significantly... (so far so good)

in some part of the application I add and delete objects... doing that, the namedquery cache is not automatically refreshed so I need to refresh it by hand at every occation that I modify the DB:

Quote:

utx.commit();
((JpaEntityManager)em.getDelegate()).getServerSession().getIdentityMapAccessor().clearQueryCache("CoverholderAgreement.all");


I do not like this option as it leads to generate new bugs... think about the case when I persist another object which by CASCADING persists a new CoverholderAgreement and I forget to refresh the namedquery cache... (this things hapends specially after some time or when future developers maintain the code and they are not aware of some cached namedquery)...

so just wondering if there is a better way for doing it ????

thanks !

[Updated on: Fri, 15 July 2011 09:22]

Report message to a moderator

Re: how to automatically refresh a cached namedquery after object insertion/deletion ? [message #698562 is a reply to message #696990] Tue, 19 July 2011 17:34 Go to previous messageGo to next message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

It would probably be a useful option to have the query cache invalidate when any object is updated. Please log a enhancement request for this.

There is currently an invalidation time that you can set, but not way for an update to trigger an invalidation, other than using events.


James : Wiki : Book : Blog : Twitter
(no subject) [message #698571 is a reply to message #696990] Tue, 19 July 2011 17:34 Go to previous messageGo to next message
James is currently offline JamesFriend
Messages: 272
Registered: July 2009
Senior Member
It would probably be a useful option to have the query cache invalidate when any object is updated. Please log a enhancement request for this.

There is currently an invalidation time that you can set, but not way for an update to trigger an invalidation, other than using events.

--
James : http://wiki.eclipse.org/EclipseLink : http://en.wikibooks.org/wiki/Java_Persistence : http://java-persistence-performance.blogspot.com/
Re: (no subject) [message #698601 is a reply to message #698571] Tue, 19 July 2011 19:19 Go to previous message
Sebastian  is currently offline Sebastian Friend
Messages: 2
Registered: July 2011
Junior Member
tracked in https: //bugs.eclipse.org/bugs/show_bug.cgi?id=352500
Previous Topic:Eclipselink.ddl-generation : drop-and-create-tables don't drop tables
Next Topic:extending a bundle with entities from an other bundle?
Goto Forum:
  


Current Time: Tue Nov 25 01:57:40 GMT 2014

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

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