greetings folks :) I have a problem with caching with ehcache + hibernate.
I have a base class (class A) which is extended by four classes (B, C, D, E). The four classes are actually the ones used in the code to perform loads, queries, save and whatever needed. This reflects an is-a relationship on the database. The classes are mapped like that:
Code:
<class name="it.mycompany.A" table="a_table" lazy="true">
[...]
<joined-subclass name="it.mycompany.B" table="b_table" lazy="true">
[...]
</joined-subclass>
<joined-subclass name="it.mycompany.C" table="c_table" lazy="true">
[...]
</joined-subclass>
</class>
I need to boost my application's performance, so I enabled caching: I've added a default ehcache.cfg.xml file (copied straight from the tutorial) and added the following line on hibernate.cfg.xml:
<class-cache class="it.mycompany.B" usage="read-write"/>
ehcache starts correctly and caches other entities in the mapping. However, if I add the line above, I get a message like
"You may only specify a cache for root <class> mappings"
however, it's the child classes I need cached, because those are the ones that are used with the code... hibernate generates joined queries, and having just the superclass cached would do me no good.
Thanks in advance for any help, I'm really at a loss here.
Hibernate version: hibernate 3 + ehcache 1.0
Mapping documents: specified in message
Full stack trace of any exception that occurs:Code:
2008-01-04 14:44:03,039 FATAL [main] hibernate.HibernateUtil (HibernateUtil.java:70) - Creazione iniziale di una SessionFactory Hibernate fallita
org.hibernate.MappingException: You may only specify a cache for root <class> mappings
at org.hibernate.cfg.Configuration.getRootClassMapping(Configuration.java:1402)
at org.hibernate.cfg.Configuration.setCacheConcurrencyStrategy(Configuration.java:1422)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1241)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1217)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1184)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1112)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1098)
Name and version of the database you are using: Mysql 5.0.27