-->
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: Multiple hibernate applications accessing a single database
PostPosted: Wed Mar 22, 2006 2:23 am 
Newbie

Joined: Wed Mar 22, 2006 2:04 am
Posts: 1
I am in the early design phase for a system that will comprise of two individual applications (a web-application and an Oracle portal application). They will both access a single Oracle database.

My concern is that changes made to the data by one application will not be immediately reflected in the other application due to the caching features of Hibernate.

Options I have considered include:
1) switching caching off and relying purely on the database vendors powerful memory caching features. I am not sure if I can even switch hibernate caching off though
2) somehow running the 2xhibernate sessions in a cluster. i.e. the first session knows about the 2nd session and they share a cache.

I have read through the Hibernate In Action caching chapter 5, but am none the wiser about how I should proceed. Any details on the clustered applications I have found too complicated to understand. I assume this is not a new situation, and look forward to some help!

Rgds
Daniel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 22, 2006 4:27 am 
Beginner
Beginner

Joined: Fri Oct 28, 2005 7:11 am
Posts: 20
I will not write anything smart - the only option is to have cache disabled (it is one flag).


Top
 Profile  
 
 Post subject: Re: Multiple hibernate applications accessing a single datab
PostPosted: Wed Mar 22, 2006 5:28 am 
Regular
Regular

Joined: Tue Nov 16, 2004 6:36 pm
Posts: 62
Location: Zürich
beranga wrote:
Options I have considered include:
1) switching caching off and relying purely on the database vendors powerful memory caching features. I am not sure if I can even switch hibernate caching off though
2) somehow running the 2xhibernate sessions in a cluster. i.e. the first session knows about the 2nd session and they share a cache.


You should turn 2nd level caching off, except read-only cache for those data that you know that noone will change (reference data etc.).

The first level cache: you cannot really turn it off (except by using a StatelessSession), nor is there a need to do so: the 1st level cache in the session is just like what is happening anyways in any application: as long as you have not committed your transaction you do have a local view that might be different from what others see. Any two applications using a database (or even any two transactions within the same application) must cope with that. Use optimistic locking to deal with that. If your other application is not using Hibernate (or not even using Java) of course it must cooperate and apply the same optimistic locking policy.

Option 2 is not really what is happening when using a clustered cache: this cache only applies to the second level cache, i.e. the level below the sessions. The 1st level cache (session) is always private (even within a single JVM).

So in any case, you must take care that you close the session (or evict all objects from it) after committing, so that re-reading objects will not reuse the cached (possibly stale) version of these. We always use the model where the lifespan of the hibernate session equals the database transaction.


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.