Jon,
can you please create a new issue at
http://jira.codehaus.org/browse/CASTOR, and attach a working sample
(possibly maybe following the bug submission guidelines available in the
JDO HOW-TO section at http://castor.org .. ;-)), and I will follow up
with any findings et alias.
Thanks
Werner
Jon Wilmoth wrote:
> I'm using castor-1.0M3 and am getting a PersistenceException (Object X
> links to another object, Y not loaded/updated/created in this
> transaction) with a lazy loaded 1:1 property in a txn used to query the
> primary object (in a read-only manner since I'm only rendering a web
> page, not updating the data) and load some, but not all lazy loaded
> properties.
>
> Below is the gist of what I'm doing:
>
> public class GolfCourse {
> private Long id;
> private City city;
> private Collection<GolfCourseTees> tees;
> ...
> }
> Mapping (abbreviated):
> <field name="city" type="City" lazy="true">
> <sql name="CITY_ID"/>
> </field>
> <field name="tees" type="GolfCourseTees" lazy="true"
> collection="collection">
> <sql many-key="COURSE_ID"/>
> </field>
>
> public class GolfCourseTees {
> private Long id;
> private GolfCourse course;
> private String name;
> ...
> }
> <field name="id" type="long">
> <sql name="ID" type="bigint"/>
> </field>
> <field name="course" type="com.apex.mytracker.app.golf.GolfCourse"
> required="true" lazy="false">
> <sql name="COURSE_ID"/>
> </field>
> <field name="name" type="string" required="true">
> <sql name="TEES_NAME" type="char"/>
> </field>
>
> //start txn
> db.begin();
>
> //run query
> OQLQuery query = db.getQuery( "SELECT o FROM GolfCourse o WHERE id=$1" );
> query.bind( 5 );
> results = query.execute(AccessMode.ReadOnly);
> // Iterate over all the golf course results and load certain lazy-loaded
> properties
> while ( results.hasMore() ) {
> Collection<GolfCourseTees> tees = golfCourse.getTees();
> //loop through this nested property to force them to be loaded
> in this txn
> for (GolfCourseTees tee : tees) {
> //...
> }
> }
> //cleanup
> ...
> //commit
> db.commit(); //causes exception when I don't call getCity()
>
> I searched through Jira and it looks like there's some related entries,
> but I'm not sure if I'm using the tool wrong or if this is a bug.
>
> Thanks,
> Jon
-------------------------------------------------
If you wish to unsubscribe from this list, please
send an empty message to the following address:
[EMAIL PROTECTED]
-------------------------------------------------