-
1. Re: JBC Strategie with JPA/Hibernate
manik Apr 6, 2009 5:39 AM (in response to zeravlai)If you are referring to a cache loader, I can't imagine why you would use a cache loader if you are using JBC with Hibernate, since Hibernate already provides persistence.
Using cache loaders with JBC is really for cases where you want cached in-memory state to be persisted (e.g., to disk or a DB) so it survives restarts and it can be evicted from memory when the cache hits certain thresholds.
In the case of a Hibernate 2nd level cache, this is unnecessary since any state in the cache already exists in Hibernate. -
2. Re: JBC Strategie with JPA/Hibernate
zeravlai Apr 6, 2009 8:03 AM (in response to zeravlai)Thanks Manik,
I was really looking for a solution to have two clustered nodes with one db each, and get the dbs in synch in the same way the cache is.
If I'm using load balancing, app calls will be balanced between nodes. Cache data will be in synch, but db data will NOT. Imaging tx1 goes to node1 to modify customer 1. Either by invalidation or replication, the two caches will be in synch, but just db1 will hold the modification to customer 1, while db2 won't know about that modification.
Should I be using a third party software to get the two dbs in synch?? -
3. Re: JBC Strategie with JPA/Hibernate
zeravlai Apr 9, 2009 6:37 PM (in response to zeravlai)The following sentence makes me believe the only consistent cache strategy is using a single database for all nodes in the cluster. It is in "Chapter 2. Core Concepts" of hibernate 3.3.1 guide:
Concurrent cache updates of the same entity anywhere in the cluster should not be possible, as Hibernate will acquire an exclusive lock on the database representation of the entity before attempting to update the cache.
Should I be using the same DB for all nodes?
Is there any solution you can think of to be using one DB per node and have the DBs in synch as the cache is ? -
4. Re: JBC Strategie with JPA/Hibernate
brian.stansberry Apr 9, 2009 6:55 PM (in response to zeravlai)If you want multiple DBs, you either:
1) Rely on the clustering capabilities of your database vendor.
2) Use middleware like HA-JDBC[1] or Sequoia.
Trying to use the JBoss Cache used as the Hibernate 2nd Level Cache to keep your DBs in sync is definitely not the way to go.
[1] http://ha-jdbc.sourceforge.net . Founded/led by my colleague in the JBoss AS Clustering team, Paul Ferraro. See some links on the bottom of that page for other related tech.