-->
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: Dynamic Model to fetch data(getting Exptn when fetch="j
PostPosted: Thu Oct 23, 2008 1:50 am 
Newbie

Joined: Thu Oct 23, 2008 1:42 am
Posts: 1
Location: Kolkata, India
Hi,

I am using dynamic model to fetch data.
entity.hbm.xml:
============
<hibernate-mapping default-lazy="false">
<class entity-name="en_table1" table="table1">
<id name="tab_id1" column="tab_id1" type="integer"/>
<property name="tab_name1" column="tab_name1" type="string" />
<set name="en_table2s" fetch="join" lazy="false">
<key column="tab_id1"/>
<one-to-many class="en_table2"/>
</set>
</class>
<class entity-name="en_table2" table="table2">
<id name="tab_id2" column="tab_id2" type="integer"/>
<property name="tab_name2" column="tab_name2" type="string" />
<set name="en_table3s" fetch="join" lazy="false">
<key column="tab_id2"/>
<one-to-many class="en_table3"/>
</set>
</class>
<class entity-name="en_table3" table="table3">
<id name="tab_id3" column="tab_id3" type="integer"/>
<property name="tab_name3" column="tab_name3" type="string" />
</class>
</hibernate-mapping>

Data Access Code:
================
Object o=session.get("en_table1",1);

Getting error:
================
org.hibernate.LazyInitializationException: illegal access to loading collection
at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:363)
at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:108)
at org.hibernate.collection.PersistentSet.hashCode(PersistentSet.java:434)
at java.util.HashMap$Entry.hashCode(Unknown Source)
at java.util.AbstractMap.hashCode(Unknown Source)
at java.util.HashMap.put(Unknown Source)
at java.util.HashSet.add(Unknown Source)...........

#####
The problem arises from the second level Set (here, 'set name="en_table3s"' ). For first level set only('set name="en_table2s"') the problem doesn't arise.
Though can be solved by:
<set name="en_table3s" fetch="select" lazy="false">. But, I have to use fetch="join".
So, what should I do now? Please help.

Hibernate Version: hibernate-distribution-3.3.1.GA
Database: Oracle 10g

_________________
Prosenjit Chakraborty


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.