©©Rely-On
Rely-On 2005;
2005; For further
For further information
information on Rely-On,
on Rely-On, please
please visit visit www.rely-ongroup.com
www.rely-ongroup.com
Hibernate Workshop
Mandatory
Pluggable
• read-write
– Maintains read committed isolation, using a timestamping mechanism.
– only in non-clustered environments.
– use this strategy for read-mostly data
• nonstrict-read-write
– Makes no guarantee of consistency between the cache and the database.
– configure a sufficiently short expiry timeout.
– Use this strategy if data rarely changes (many hours, days or even a week) and a
small likelihood of stale data isn’t of critical concern.
• read-only
– A concurrency strategy suitable for data which never changes.
– Use it for reference data only.
Features Supported
For POJOs
For collections
ehcache.xml
<cache name="org.hibernate.auction.model.Category"
maxElementsInMemory="500"
eternal="true"
timeToIdleSeconds="0"
timeToLiveSeconds="0"
overflowToDisk="false"/>
hibernate.cfg.xml
<property name="c3p0.acquire_increment">1</property>
<property name="c3p0.idle_test_period">100</property>
<property name="c3p0.max_size">100</property>
<property name="c3p0.max_statements">0</property>
<property name="c3p0.min_size">10</property>
<property name="c3p0.timeout">100</property>
• idleTestPeriod c3p0 will test all idle, pooled but unchecked-out connections. Must be set in
hibernate.cfg.xml (or hibernate.properties), Hibernate default: 0
• propertyCycle Must be set in c3p0.properties, C3P0 default: 300 Maximum time in seconds before
user configuration constraints are enforced. c3p0 enforces configuration constraints continually,
and ignores this parameter. It is included for JDBC3 completeness.
• testConnectionOnCheckout Must be set in c3p0.properties, C3P0 default: false Don't use it, this
feature is very expensive. If set to true, an operation will be performed at every connection checkout
to verify that the connection is valid. A better choice is to verify connections periodically using
c3p0.idleConnectionTestPeriod.
• autoCommitOnClose Must be set in c3p0.properties, C3P0 default: false The JDBC spec is
unfortunately silent on what should happen to unresolved, pending transactions on Connection
close. C3P0's default policy is to rollback any uncommitted, pending work.
• factoryClassLocation Must be set in c3p0.properties, C3P0 default: null DataSources that will be
bound by JNDI and use that API's Referenceable interface to store themselves may specify a URL
from which the class capable of dereferencing a them may be loaded. If (as is usually the case) the
c3p0 libraries will be locally available to the JNDI service, leave this set to null.
– Strategy
Read/write
– needs to update data
– never be used if serializable transaction isolation level is required
Nonstrict read/write
– occasionally needs to update data
– strict transaction isolation is not required