-->
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: second level cache / collection-cache problem
PostPosted: Tue May 31, 2005 4:56 am 
Newbie

Joined: Fri May 20, 2005 2:42 am
Posts: 14
Hello,

i have a question concerning the second level cache and caching collections. I have a business object that has a list of security Objects. In the first step i want to load all security Objects
into the second level cache, which works fine. The objects are stored
in the second level cache using their primary key. After that i want to
load all my business objects from the db. this works but the security objects are still loaded from the db and are not taken
from the second level cache, even though all the securities are
available in the second level cache and i am using the collection-cache
mapping. Looking at the hibernate log i can see that hibernate checks
the second level cache for the security objects. however it is using the
primary key of the business object to find the securities (of my
securities set), which
does not work, of course. what i do not understand is why it is using the
primary key of business object ? when using that pk it can never find
more than one security object because the pk has to be unique.
this way my set of securities can never have more than one element.
is it a problem that i have a composite-id for both classes which do
not have exactly the same attribute / values ? both keys share the
kontoNrSub and the kontoNr attributes (the security class has an
additional attribute). I expected that hibernate would take the defined
key columns from the set and create a new security primary key
(which would be incomplete, because of the one missing attribute in
the association), which hibernates uses to get all securites from the
second level cache which match that partial primary key ?
I do not know if this is possible at all ?

any ideas ?

thanks in advance,
Andreas


Hibernate version:
3.0.5

Mapping documents:
Code:
hibernate.cfg.xml :
<class-cache class="Business" usage="read-write"/>
<class-cache class="Security" usage="read-write"/>
<collection-cache collection="Business.securities" usage="read-write"/>

mapping files :
<hibernate-mapping auto-import="false">

  <class name="Business" table="Business_VW" lazy="false">
   
    <composite-id name="id" class="BusinessPK">
      <key-property name="kontoNr" type="java.lang.Long">
        <column name="KONTO_NR" scale="15" precision="0" not-null="true" sql-type="NUMBER" />
      </key-property>
      <key-property name="kontoNrSub" type="java.lang.Long">
        <column name="KONTO_NR_SUB" scale="15" precision="0" not-null="true" sql-type="NUMBER" />
      </key-property>
    </composite-id>

    <set name="securities" lazy="true" outer-join="false" cascade="save-update" batch-size="200">
      <key>
        <column name="KONTO_NR" scale="15" precision="0" not-null="false" />
        <column name="KONTO_NR_SUB" scale="15" precision="0" not-null="false" />
      </key>
      <one-to-many class="Security" />
    </set>
   
  </class>
</hibernate-mapping>


<hibernate-mapping auto-import="false">

  <class name="Security" table="Security_VW" lazy="false">
   
    <composite-id name="id" class="SecurityPK">
      <key-property name="SicherungsId" type="java.lang.String">
        <column name="SICHERUNGS_ID" scale="100" precision="0" not-null="true" sql-type="VARCHAR2" />
      </key-property>
      <key-property name="KontoNr" type="java.lang.Long">
        <column name="KONTO_NR" scale="15" precision="0" not-null="true" sql-type="NUMBER" />
      </key-property>
      <key-property name="KontoNrSub" type="java.lang.Long">
        <column name="KONTO_NR_SUB" scale="15" precision="0" not-null="true" sql-type="NUMBER" />
      </key-property>
    </composite-id>

<!--    .... some properties ... -->
   
  </class>
</hibernate-mapping>


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.