Friday, March 12, 2010

hibernate cache injection: missing…

Tagged with: ,
Monday, January 7, 2008, 2:04
This news item was posted in Notes category and has 2 Comments so far.

currently hibernate version is 3.2.5 and there is still something basic missing: cache injection.

while you are using spring or another container you can configure hibernate by injection. e.g:your own datasource definition,your dialect , your hibernate interceptors.

but you can not inject your caching mechanism because hibernate only accept hibernate.cache.provider_class

Result: you can not share your caching mechanism with hibernate or manage hibernate caching mechanism.

<bean id="MySessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="mappingResources">
<list>
<value>mappings/Book.hbm.xml</value>
<value>mappings/Patron.hbm.xml</value>
<value>mappings/BorrowRecord.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.query.substitutions">true=1 false=0</prop>
<prop key="hibernate.show_sql">false</prop>
<prop key="hibernate.use_outer_join">false</prop>
</props>
</property>
<property name="dataSource"><ref bean="MyDataSource"/></property>
</bean>

some good idea to look : Caching the result of methods using Spring and EHCache

Share and Enjoy:
  • Digg
  • del.icio.us
  • Netvouz
  • DZone
  • Wists
  • LinkedIn
  • Slashdot
  • Google Bookmarks
  • Reddit
  • StumbleUpon
  • email
  • Twitter

Related posts:

  1. hibernate tip: smart id generator
  2. Are you clearing your cache manually ?
  3. JGroups Basics
  4. who needs implementations?
  5. Clustering Acegi via JGroups (DistributedHashtable)

You can leave a response, or trackback from your own site.

2 Responses to “hibernate cache injection: missing…”

  1. Halcyon said on Monday, January 7, 2008, 20:55

    It should also be noted that as Spring has evolved, it has become even easier to integrate EHCache into method calls (than even the example in the link shows, which is quite old). Add three existing bean definitions to your app context, an XML config file for ehcache, some annotations on your cacheable methods, and you’re done. This means you can use ibatis or hibernate interchangeably without concern for data access mechanisms. You also get the established benefits of EHCache with regards to distributed caching, with no extra coding.

  2. altuure said on Tuesday, January 8, 2008, 1:25

    thanks Halcyon,
    One more note,

    this a feature request which is considerably easy and effective I guess
    http://opensource.atlassian.com/projects/hibernate/browse/HHH-3054

Leave a Reply