-->
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.  [ 3 posts ] 
Author Message
 Post subject: New to Hibernate + EHCache
PostPosted: Fri Feb 06, 2009 6:46 am 
Beginner
Beginner

Joined: Wed Dec 10, 2008 5:59 am
Posts: 47
Hi,

I am trying to get EH cache to work with my application, and it seems to do a good job most of the time. However, for one particular class i get the error below. The interesting part is that this error only occurs when i activate EHCache. Without it, everything works just fine (with both Hibernate 3.2.5 and Hibernate 3.3.1)


Quote:
9032 [SwingWorker-pool-2-thread-4] WARN org.hibernate.engine.loading.LoadContexts - fail-safe cleanup (collections) : org.hibernate.engine.loading.CollectionLoadContext@1b29f80<rs=com.mysql.jdbc.JDBC4ResultSet@913c56>
9032 [SwingWorker-pool-2-thread-4] WARN org.hibernate.engine.loading.CollectionLoadContext - On CollectionLoadContext#cleanup, localLoadingCollectionKeys contained [1] entries


The class in question is mapped as follows:

Code:
<hibernate-mapping>
    <class name="com.tracker.db.entities.KeywordNode" table="keywordnode">
        <cache usage="read-write" />

        <id column="id" length="36" name="id" type="com.tracker.db.usertypes.CustomUUID"/>
        <discriminator column="type" not-null="true" type="java.lang.String"/>
        <property column="name" length="200" name="name" type="java.lang.String"/>
        <many-to-one cascade="none" class="com.tracker.db.entities.KeywordNode" column="parent_id" name="parent" lazy="false" />
        <property column="status" length="1" name="status" type="java.lang.Integer"/>
        <property column="flag" length="1" name="flag" type="java.lang.Integer"/>
        <property name="updated" type="java.util.Calendar">
            <column name="updated" sql-type="Date"/>
        </property>

        <bag cascade="all" inverse="true" name="children">
            <key column="parent_id"/>
            <one-to-many class="com.tracker.db.entities.KeywordNode"/>
        </bag>

        <subclass discriminator-value="ROOT" name="com.tracker.db.entities.KeywordRoot" />
        <subclass discriminator-value="TYPE" name="com.tracker.db.entities.KeywordType" />
        <subclass discriminator-value="KEYWORD" name="com.tracker.db.entities.Keyword">
            <set cascade="all" inverse="true" lazy="false" name="synonyms">
                <key column="keywordnode_id"/>
                <one-to-many class="com.tracker.db.entities.Synonym"/>
            </set>
        </subclass>
    </class>
</hibernate-mapping>




I suspect this has something do to with the fact that the class in question represents a node in a tree, and have associations to the same class as parent (and a bag of children). When i remove the mapping to the parent, things also work fine.

Do i need to map my hierarchy structure differently? Is there something EHCache & Hibernate can't really cope with in this situation?

All hints & tips are most welcome!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 06, 2009 7:37 am 
Regular
Regular

Joined: Fri Jan 30, 2009 10:10 am
Posts: 74
Location: London
Are you sure that you want to use a bag to contain the children?

Do you really want to allow duplicates?

I know that bags can make things complicated in certain situations, and this could be one of them.

--
Stephen Souness


Top
 Profile  
 
 Post subject: Bag (=ArrayList) vs. Set
PostPosted: Fri Feb 06, 2009 8:57 am 
Beginner
Beginner

Joined: Wed Dec 10, 2008 5:59 am
Posts: 47
Thanks for your reply. Do you think that is the issue?

The reason for using a bag is that i need to retrieve the children in a collection which can guarantee the order of the elements - as i use them directly in a TreeModel which requires that child elements of a node can be accessed by index.

However, if the bag-vs-set cause this problem - i'd for sure try and change it. Any suggestions on that?


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

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.