-->
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: SecondLevelCache not enabled when <union-subclass> is
PostPosted: Thu Mar 24, 2005 1:11 pm 
Newbie

Joined: Mon Mar 07, 2005 7:27 pm
Posts: 6
I am using <union-subclass> construct in one of my mapping files. AttributeValue is the superclass and StringAttributeValue and IntegerAttributeValue are union-subclasses. Enabling cache for AttributeValue does not enable cache for the subclasses. Is this an expected behavior ?

Hibernate version: Hibernate3

Mapping documents:
Code:
<class name="package.AttributeValue">
      <cache usage="read-write"/>
      <id
         name="id"
         column="ID"
         unsaved-value="0">
         <generator class="increment"/>
      </id>
    <union-subclass name="package.StringAttributeValue" table="STRINGATTRIBUTE">
      <property name="value">
         <column name="VALUE" not-null="true" unique="true" index="STRATT_VAL_IDX"/>
      </property>   
    </union-subclass>
    <union-subclass name="package.IntegerAttributeValue" table="INTEGERATTRIBUTE">
      <property name="value">
         <column name="VALUE" not-null="true" unique="true" index="INTATT_VAL_IDX"/>
      </property>   
    </union-subclass>
</class>

Printing entries in "names" array in the following code
Code:
        String[] names = HibernateUtil.getSessionFactory().getStatistics().getSecondLevelCacheRegionNames();

does not list StringAttributeValue and IntegerAttributeValue.

A typical HQL in my application would look like
Code:
"from StringAttributeValue sav where sav.value=:nameString"

I want this query to look in the cache before it goes to the db. But it is not happening. It always checks in the db and because of that I get duplicate StringAttributeValue/IntegerAttributeValue objects thus violating unique constraint on value columns.

Any thoughts ?


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.