Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.0 M1, 1.0 M2, 1.0 M3
-
Fix Version/s: 1.0.1
-
Component/s: JDO lazy loading
-
Labels:None
-
Environment:jdk 1.5.0_04, mysql 4.1.16-nt, mysql Driver Version: mysql-connector-java-3.0.17-ga
-
Number of attachments :
Description
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
Attachments
Issue Links
| This issue relates to: | ||||
| CASTOR-1365 | PersistenceException while creating object with lazy-loaded independent objects |
|
|
|
Zip containing: