Showing posts with label hibernate. Show all posts
Showing posts with label hibernate. Show all posts

Tuesday, 5 July 2011

Cascading Persistence in Hibernate

We have said, a number of times, that when an object is made persistent, that the objects it refers to are also made persistent. This was an oversimplification. In the mapping files for the classes, there is an attribute, cascade that lets us control how much, or how little, of a reference graph gets automatically persisted, deleted or updated. The values that it can be set to, and their meanings, are as follows:
  • none: no automatic action on the referenced object takes place.
  • save-update: automatically save or update the referenced object when the referencing object is saved or the transaction commits.
    delete: automatically delete the referenced object when delete() is called on the referencing object. Note that, if the referencing object is not deleted but merely removes its reference to the referenced object, then this option will not do anything and, potentially, a garbage (or orphan) object will be left in the database.
  • delete-orphan: automatically delete any object for whom the reference has been removed from the referencing object.
  • all: take the same actions as save-update and delete but not that of delete-orphan.
  • all-delete-orphan: take the same action as save-update, delete and delete-orphan.

Wednesday, 15 June 2011

List of Cache Provider in Hibernate and their concurrency support details


Here in this port you can find the list of Cache providers and their Concurrency support details. (Exerted from Official Hibernate Tutorial)
EHCache (Easy Hibernate Cache)
(org.hibernate.cache.EhCacheProvider)
  • It is fast.
  • lightweight.
  • Easy-to-use.
  • Supports read-only and read/write caching.
  • Supports memory-based and disk-based caching.
  • Does not support clustering.
OSCache (Open Symphony Cache)
(org.hibernate.cache.OSCacheProvider)
  • It is a powerful .
  • flexible package
  • supports read-only and read/write caching.
  • Supports memory- based and disk-based caching.
  • Provides basic support for clustering via either JavaGroups or JMS.
SwarmCache (org.hibernate.cache.SwarmCacheProvider)
  • is a cluster-based caching.
  • supports read-only or nonstrict read/write caching .
  • appropriate for applications those have more read operations than write operations.
JBoss TreeCache (org.hibernate.cache.TreeCacheProvider)
  • is a powerful replicated and transactional cache.
  • useful when we need a true transaction-capable caching architecture .
Cache providers.
Cache
Provider class
Type
Cluster Safe
Query Cache Supported
Hashtable (not intended for production use)
org.hibernate.cache.
HashtableCache
Provider
memory
yes
EHCache
org.hibernate.cache.
EhCacheProvider
memory, disk
yes
OSCache
org.hibernate.cache.
OSCacheProvider
memory, disk
yes
SwarmCache
org.hibernate.cache.
SwarmCacheProvider
clustered (ip multicast)
yes (clustered invalidation)
yes (clock sync req.)
JBoss Cache 1.x
org.hibernate.cache.
TreeCacheProvider
clustered (ip multicast), transactional
yes (replication)
yes (clock sync req.)
JBoss Cache 2
org.hibernate.cache.
jbc2.JBossCache
RegionFactory
clustered (ip multicast), transactional
yes (replication or invalidation)
yes (clock sync req.)
Cache Concurrency Strategy Support
Cache
read-only
nonstrict-read-write
read-write
transactional
Hashtable (not intended for production use)
yes
yes
yes
EHCache
yes
yes
yes
OSCache
yes
yes
yes
SwarmCache
yes
yes
JBoss Cache 1.x
yes
yes
JBoss Cache 2
yes
yes