-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Hibernate + ehcache + extended classes: trouble :)
PostPosted: Fri Jan 04, 2008 9:48 am 
Newbie

Joined: Fri Jan 04, 2008 9:19 am
Posts: 4
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.