Hi folks,
does anyone managed to use a lazy loading feature
with long transactions? I do have a biderectional 1:N relationship between
Master and Detail objects.
My mapping file is:
<class name="Master" identity="id"
access="shared" key-generator="IDENTITY">
...
<field name="details" type="Detail" lazy="true" collection="collection"> <sql many-key="MasterID" /> </field> </class> <class name="Detail" identity="id"
key-generator="IDENTITY">
...
<field name="master" type="Master" > <sql name="MasterID" /> </field> </class> i'm loading a master object in short transaction
and close it just after master object was loaded, so master.getDetails method
will give me a RelationCollection with only detail identities loaded.
...
db.begin();
master =
(Master)db.load(...);
db.commit();
db.close()
...
Collection list =
master.getDetails();
Iterator itr = list.iterator(); while (itr.hasNext()) { Object o = itr.next(); // <--- this line gets an error System.out.println(o); }
And, when i trying to go through the details
collection it gives me an error: "Transaction is closed!":
java.lang.RuntimeException: Transaction is
closed!
at
org.exolab.castor.persist.RelationCollection$IteratorImp.lazyLoad(Unknown
Source)
at
org.exolab.castor.persist.RelationCollection$IteratorImp.next(Unknown
Source)
...
Any ideas how to avoid that problem?
Thanks, Denis.
|
- Re: [castor-dev] Lazy loading with long transaction Denis Sukhoroslov
- Re: [castor-dev] Lazy loading with long transacti... Denis Sukhoroslov
- Re: [castor-dev] Lazy loading with long trans... Arijit Ghosh
- Re: [castor-dev] Lazy loading with long transacti... Dmitry Vereshchagin
- Re: [castor-dev] Lazy loading with long trans... Denis Sukhoroslov