• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
  • Tim Holloway
  • Carey Brown
  • salvin francis

using ehcache with hibernate please answer this

Ranch Hand
Posts: 123
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have a very few basic but important question about hibernate.
i have a POJO defined as category and i have set the cache as read-only and i integrated Ehcache with my project on second level.
Here is a snippet from my application-context file, i have sepcified the ehcahce provider
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource"><ref local="dataSource"/></property>
<property name="mappingResources">
<value>com/hyderabad/model/hibernate/User.hbm.xml</value> <value>com/hyderabad/model/hibernate/Category.hbm.xml</value>

<property name="hibernateProperties">
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
The next thing i did was in my Category.hbm.xml file i gave the cache usage something like this
<class name="com.hyderabad.model.Category" table="category">
<cache usage="read-only" />
<id name="categoryId" column="category_id">
<generator class="increment"/>
<property name="categoryName">
<column name="category_name" />
<property name="parentCategoryId">
<column name="parent_category_id" />
And in my ehcache.xml file i have this
<diskStore path="java.io.tmpdir"/>


<cache name="com.hyderabad.model.Category"

I have the following questions...
1) i gave the maximum elements for category to be 3 but when i run my project i get all the 20 categories. Why? My wild guess i read in some forums i have to enable second level categories by using some property element.

2)When i start my container i get 20 categories. Ok fine, but when i add manually some more categories in my database table and refresh the page those new entries are showing up, i thought if you implement the cache usage as read only and at the second level (at session factory level) then the server should be bounced to read the newly added categories. i am having a wrong about it.

Any advice.

Darvesh Niz
Ranch Hand
Posts: 123
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
any advice or opinion please

Switching from electric heat to a rocket mass heater reduces your carbon footprint as much as parking 7 cars. Tiny ad:
professionally read, modify and write PDF files from Java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!