-->
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.  [ 2 posts ] 
Author Message
 Post subject: hydrate a list of objects during a load from the database
PostPosted: Wed Aug 16, 2006 9:29 am 
Newbie

Joined: Wed Aug 16, 2006 8:50 am
Posts: 2
Hello everybody,

This is my first attempt at using hibernate (3.2) and I am running into an issue with many-to-many associations. I have a desktop application and its interaction to the database only happens when the user saves and exits or loads from the database when the application is booted up. There is no retrieving/saving of data on a page-by-page basis.

Now I have a StatementOfOrder object which contains lines of AccountingItems, and an AccountingItem can be contained in multiple StatementOfOrders. My hibernate mapping for the StatementOfOrder table looks like this--

Code:
        <list name="accountingItems" table="SOO_ITEMS" lazy="false" cascade="save-update">
            <key column="SOO_ID"/>
            <index column="INDEX"/>
            <many-to-many
                column="ITEM_ID"
                class="AccountingItem"
                fetch="join"/>
        </list>


When the user saves their data, exits the application, and then loads the data on application startup, the list of accountingItems does not get populated (or I hear the other term 'hydrated'). The StatementOfOrder object gets 'hydrated' appropriately--I can see its UUID--but when I iterate over the list of AccountItems, they return the appropriate items in order but are not populated (no UUIDs set).

I tried adding the attribute 'fetch="join"' to the list element but get some kind of lazy initialization exception. I retrieve the StatementOfOrder object from the database like this--

Code:
StatementOfOrder soo = (StatementOfOrder)query.uniqueResult();


So how can I force hibernate to hydrate my list of AccountItems when the user loads data from the database?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 16, 2006 5:28 pm 
Newbie

Joined: Wed Aug 16, 2006 8:50 am
Posts: 2
I added the fetch="join" attribute to the list element to force hydration and this is the error I get:

Code:
Aug 16, 2006 4:08:36 PM org.hibernate.LazyInitializationException <init>
SEVERE: illegal access to loading collection
org.hibernate.LazyInitializationException: illegal access to loading collection
        at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:341)
        at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:86)
        at org.hibernate.collection.PersistentList.toString(PersistentList.java:351)
...


So I'm at a lost right now.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.