hibernate cache injection: missing…

Monday, January 7, 2008 2:04
Posted in category Notes

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
  • Technorati
  • YahooMyWeb
  • Furl
  • Slashdot
  • Google Bookmarks
  • Reddit
  • TwitThis
  • StumbleUpon
  • E-mail this story to a friend!

Related posts:

  1. hibernate tip: smart id generator
  2. Are you clearing your cache manually ?
  3. who needs implementations?
  4. hibernate native Id generator tip
  5. Spring is totally losing its invisibility

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

2 Responses to “hibernate cache injection: missing…”

  1. Halcyon says:

    January 7th, 2008 at 8:55 pm

    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 says:

    January 8th, 2008 at 1:25 am

    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