-->
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.  [ 5 posts ] 
Author Message
 Post subject: Cache Invalidation with Large Collections
PostPosted: Wed May 23, 2007 12:14 pm 
Newbie

Joined: Wed May 23, 2007 12:10 pm
Posts: 4
Hey all,

I have a large DB table I need to insert into and was therefore using session.createSQLQuery() to avoid having to load the collection to do this. This however seems to invalidate all my caches. I know that it has no effect on any of them. How can I prevent the caches from being invalidated?

Cheers,

Dan


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 23, 2007 8:51 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
You could get the sessions connection and insert using straight JDBC (Note: the API is/has changed in this area). Alternatively, I would look at the type of mapping that you have for the collection so you can avoid loading all of it.


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 24, 2007 5:45 am 
Newbie

Joined: Wed May 23, 2007 12:10 pm
Posts: 4
Hi David,

Thanks for your help. We have considered using straight JDBC but would prefer to find a hibernate solution. Can you suggest any mappings that won't load the entire collection upon update?

Cheers,

Dan.


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 24, 2007 6:42 pm 
Newbie

Joined: Tue May 16, 2006 8:54 pm
Posts: 5
daniel_1979 wrote:
Hi David,

Thanks for your help. We have considered using straight JDBC but would prefer to find a hibernate solution. Can you suggest any mappings that won't load the entire collection upon update?

Cheers,

Dan.


If refactoring the data model is an option, you can create a new entity that represents the relationship itself then simply do a one-to-many on that. You can then persist new ones without triggering a full collection load.


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 24, 2007 9:35 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
See reference docs for bi-directional mapping of a collection using a bag. This can be updated without the collection being initialised.

see http://www.hibernate.org/hib_docs/v3/reference/en/html/performance.html#performance-collections-mostefficientupdate


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.