Java Mailing List Archive

Home » user.castor »

[castor-user] Lazy loaded collections not read-only


Replies: Find Java Web Hosting

Author LoginPost Reply
Hello list,

We noticed an unexpected behaviour with Castor 1.3.1 and Castor 1.3.3 RC1.

We use lazy loading for
collections. When we load an object (the "parent object")
in read-only method the elements ("child objects") in
collections for that object
are not read-only.

That is changes to parent object attributes are not persistent,
changes to the child
objects attributes are persistent.

When we disable the lazy loading for collections the child
object are read-only as

Is this behaviour actually expected that lazy loaded collections are not read-only

even if the parent object is read-only?

in pseudo code:
ParentPO parentPO = org.exolab.castor.jdo.Database.load
(ParentPO.class, id, Database.READONLY);
ChildrenPO childrenPO = parentPO.getChildren().iterator().next(); //assuming
non empty list
parentPO.setParentName("name change"); // change is not persistent
change"); // change is persistent

I hope the attach gives more detailed information.

thanks very much for your
attention, best regards
Justin Case

Attachment: (zipped)
Attachment: (zipped)
<?xml version="1.0"?>
<!DOCTYPE mapping PUBLIC "-//EXOLAB/Castor Mapping DTD Version 1.0//EN"
 <class name="com.example.castor.ParentPO" identity="parentId"
   access="shared" key-generator="IDENTITY" auto-complete="false">
   <map-to table="PARENT" />
   <cache-type type="time-limited" capacity="1800" />
   <field name="parentId" type="integer">
     <sql name="parent_id" type="integer" />
   <field name="parentName" type="string">
     <sql name="parent_name" type="char" />
   <field name="children" type="com.example.castor.ChildrenPO"
     lazy="true" collection="collection">
     <sql many-key="parent_id_fk" />

 <class name="com.example.castor.ChildrenPO" identity="childrenId"
   access="shared" key-generator="IDENTITY" auto-complete="false">
   <map-to table="CHILDREN" />
   <cache-type type="time-limited" capacity="1800" />
   <field name="childrenId" type="integer">
     <sql name="children_id" type="integer" />
   <field name="childrenName" type="string">
     <sql name="children_name" type="char" />


To unsubscribe from this list, please visit:
©2008 - Jax Systems, LLC, U.S.A.