Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » JPA caching
JPA caching [message #1006336] Wed, 30 January 2013 21:40 Go to next message
Super User is currently offline Super User
Messages: 9
Registered: January 2013
Junior Member
Greetings,

Could somebody help me to find answer does EclipseLink JPA implementation NativeQuery cache results of stored procedure execuing like
call get_entities(2,3,2);



Is here some way to have stored procedures excection result cached with JPA otherwise?


Greatest thanks in advance,
Re: JPA caching [message #1007353 is a reply to message #1006336] Tue, 05 February 2013 15:38 Go to previous messageGo to next message
James Sutherland is currently offline James Sutherland
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

If your stored procedure returns entity objects, then they will be cached in the object cache.

If it does not return objects, or you wish to cache the result of the stored procedure call, then you can use a query cache for the query.

See,
http://wiki.eclipse.org/EclipseLink/UserGuide/JPA/Basic_JPA_Development/Caching/Query_Cache


James : Wiki : Book : Blog : Twitter
Re: JPA caching [message #1007746 is a reply to message #1007353] Thu, 07 February 2013 11:58 Go to previous messageGo to next message
Super User is currently offline Super User
Messages: 9
Registered: January 2013
Junior Member
Greetings Mr. Sutherland,

Thank you for your response. It is really helpful for me.
I have read EclipseLink wiki articles, but unfortunately it avoids me does JPA keep cache actual on delete or create data from tables stored procedures call.

For example we have table db_entities, object model
/*
Entity declarations 
*/
class CurrentEntity{
/*
Id and serialization declarations 
*/
private Long id;

/*
Column declarations
*/
private String name;
}


And stored procedures for create and delete data:
begin
delete from db_entities where id=param;
end;

begin
insert into db_entities values(name /*, etc.*/);
end;


Could you please help to find answer the question will JPA Cache track database table changes on these stored procedures call?

Greatest thanks in advance,

[Updated on: Thu, 07 February 2013 11:58]

Report message to a moderator

Re: JPA caching [message #1007857 is a reply to message #1007746] Thu, 07 February 2013 18:55 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris Delahunt
Messages: 1034
Registered: July 2009
Senior Member
The query cache is used to avoid executing the query a second time. The hints shown in the link can only be added to and used with read queries and should not be added to a query that modifies data, and data modified through native SQL, procedure or even bulk update+delete do not change the data that has been cached. This is part of why the link suggests using it for data that is relatively static or read only.

Can you explain what it is you are looking to cache and why?

Best Regards,
Chris

[Updated on: Thu, 07 February 2013 19:03]

Report message to a moderator

Re: JPA caching [message #1008081 is a reply to message #1006336] Fri, 08 February 2013 20:02 Go to previous message
Super User is currently offline Super User
Messages: 9
Registered: January 2013
Junior Member
Greetings Mr. Delahunt,

Thank you for your attention to my post.
My general idea is to use in my application both features of link cache feature (I assume link cache is being kept actual even on grid database architecture with right application server) and power of native sql queries (like force index, insert on duplicate key etc).

So, I'm trying to have opportunity to reach all of features to prevent making extra times database data extraction (with link cache), to obtain database performance with highly optimized JPA queries (with native sql language I assume) and to map queries result to objects (with basic link functionality).

Thank you,

[Updated on: Fri, 08 February 2013 20:07]

Report message to a moderator

Previous Topic:Alert that DCN Took Place
Next Topic:Eclipse link multiple SQL web services operations
Goto Forum:
  


Current Time: Fri Oct 24 21:26:22 GMT 2014

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

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