File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes disable  session cache for a query Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Object Relational Mapping
Reply Bookmark "disable  session cache for a query" Watch "disable  session cache for a query" New topic
Author

disable session cache for a query

sam bartl
Greenhorn

Joined: Oct 29, 2010
Posts: 26
I want to disable hibernate session cache for one criteria query , can this be done ?








Koen Aerts
Ranch Hand

Joined: Feb 07, 2012
Posts: 339

One option may be to first call the clear() method on your EntityManager instance, followed by createQuery() to execute your SQL.
sam bartl
Greenhorn

Joined: Oct 29, 2010
Posts: 26
I have a webservice, when user calls this my concern is I should not end up with out of memory error because of hibernate session size.

my application uses OpenSessionInViewFilter, spring services , all service methods are annotated with @transaction.

here is the code of my webservice impl



in the above code stgAuditGeneralService is spring service , stgAuditGeneralService.findAudits() this internally calls doa and the dao calls a criteria query , so all the entities returned by the criteria query will be in hibernate session till the session is committed am I right ?

if my webservice caller passes 10,000 AuditSearchRequest then will my session grow very big and can end up with outofmemory error ?
please advice me.



 
 
subject: disable session cache for a query
 
Threads others viewed
Expiring session
Difference between Session Cache for load and query cache ?
setCacheMode(CacheMode.IGNORE)
hibernate cache
Caching Database resultset
IntelliJ Java IDE