[hibernate-issues] [Hibernate-JIRA] Created: (HHH-3540) Dynamic model to fetch data (getting Exception when using Set with fetch="join").
Prosenjit Chakraborty (JIRA)
noreply at atlassian.com
Mon Oct 20 08:34:04 EDT 2008
Dynamic model to fetch data (getting Exception when using Set with fetch="join").
---------------------------------------------------------------------------------
Key: HHH-3540
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3540
Project: Hibernate Core
Issue Type: Bug
Affects Versions: 3.3.1
Environment: hibernate-distribution-3.3.1.GA
Reporter: Prosenjit Chakraborty
Attachments: entity.hbm.xml
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.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list