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 
expected.

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
childrenPO.setChildrenName("name 
change"); // change is persistent

I hope the attach gives more detailed information.


thanks very much for your 
attention, best regards
Justin Case

Attachment: ChildrenPO.java
Description: Binary data

Attachment: ParentPO.java
Description: Binary data

<?xml version="1.0"?>
<!DOCTYPE mapping PUBLIC "-//EXOLAB/Castor Mapping DTD Version 1.0//EN"
                         "http://castor.exolab.org/mapping.dtd";>
<mapping>
	<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>
		<field name="parentName" type="string">
			<sql name="parent_name" type="char" />
		</field>
		<field name="children" type="com.example.castor.ChildrenPO"
			lazy="true" collection="collection">
			<sql many-key="parent_id_fk" />
		</field>
	</class>

	<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>
		<field name="childrenName" type="string">
			<sql name="children_name" type="char" />
		</field>
	</class>

</mapping>


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email

Reply via email to