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.  [ 6 posts ] 
Author Message
 Post subject: Second Level Cache and ADO.NET
PostPosted: Mon Sep 10, 2007 11:29 am 
Regular
Regular

Joined: Fri Feb 09, 2007 3:47 pm
Posts: 56
If i execute an ADO.NET "delete" sentence in the database, How this affect the second level cache?
those rows deleted by the delete command, if they were in the second cache, are being deleted too?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 10, 2007 1:41 pm 
Senior
Senior

Joined: Mon Aug 21, 2006 9:18 am
Posts: 179
I believe the SysCache implements the new Sql Invalidation logic which should do what you are asking. I haven't tooled with it yet to see though. I think it is only implemented in the trunk.

_________________
If this helped...please remember to rate it!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 10, 2007 3:59 pm 
Hibernate Team
Hibernate Team

Joined: Tue Jun 13, 2006 11:29 pm
Posts: 315
Location: Calgary, Alberta, Canada
Generally speaking, NHibernate is oblivious of anything you do outside of it. Therefore, the second level cache is unaware of any raw ADO.NET operation carried out outside of the NHibernate API. As mnichols said, there is a cache provider that ties into SQL2005 (not SQL2000, I don't think) that enables NHibernate to be notified when something changed in the database. It may be the SysCache2 provider though. Once again, I am not too sure about that. If you are using any DBMS other than MS SQL2005, I believe you are out of luck.

_________________
Karl Chu


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 10, 2007 4:30 pm 
Regular
Regular

Joined: Fri Feb 09, 2007 3:47 pm
Posts: 56
Thanks. So if i want to, for example, delete some entries in a database using ADO.NET, how can i sync my database with the second level cache? If it's imposible is there any way to batch delete a lot of entries and mark as deleted those that remains in the second level cache?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 10, 2007 4:38 pm 
Hibernate Team
Hibernate Team

Joined: Tue Jun 13, 2006 11:29 pm
Posts: 315
Location: Calgary, Alberta, Canada
If you can accept the second-level cache and the database being out of sync for a short time, you can set up the cache expiration policy to a relatively short time. You may have to set up different cache regions and attach different policies to different region. Alternatively, you can manually evict the deleted entries from the second-level cache whenever you delete something. See docs here:
http://www.hibernate.org/hib_docs/nhibe ... ssioncache

_________________
Karl Chu


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 11, 2007 12:57 pm 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
You can use ISessionFactory.Evict to evict entries from the second-level cache.


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