-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Behaviour of 1. and 2. level caches when using custom SQL
PostPosted: Tue Feb 05, 2008 4:36 am 
Newbie

Joined: Tue Jan 17, 2006 5:18 pm
Posts: 4
Hibernate version: 3.1.3

Name and version of the database: MySQL 5.0.24a

Hi everyone,

I want to optimise the performance of complex delete operations (across several tables) by executing custom SQL code using a Hibernate session. I am using first and second level caches. How would a custom delete operation affect these caches since I am "bypassing" HQL and SQL code generated by hibernate.

Will hibernate automatically update its caches in such a way that any data that has been deleted by custom SQL code in the database is synchronized with the hibernate caches, or will hibernate keep data in its caches that has been deleted? What happens if another user tries to update data from a cache (eg. second level cache) which has already been deleted by custom SQL?

What are the best practices regarding custom SQL for complex delete operations?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 05, 2008 6:56 pm 
Beginner
Beginner

Joined: Mon Nov 19, 2007 4:40 pm
Posts: 46
I am currently doing this and would be interested in additional feedback. The system I am building is actually a hybrid using a proprietary solution with hibernate and so, i am often inserting/updating through the proprietary system and getting data via hibernate. From my initial tests, I found that anytime i work with the proprietary solution to insert/update/delete, I need to call refresh on the session (e.g. hibernateSession.refresh()), otherwise if I immediately retrieved the data after doing an update or delete, I got stale data.

Unfortunately, i have no idea if this is the best practice or not... I would be interested in other's feedback.

HTH,

Paul


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 07, 2008 8:47 am 
Beginner
Beginner

Joined: Mon Nov 19, 2007 4:40 pm
Posts: 46
If my response has been helpful, please rate...


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.