Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="test.A"
table="A"
proxy="test.A">
<jcs-cache usage="read-write"/>
<id name="id" column="id" type="long">
<generator class="assigned">
</generator>
</id>
<any name="anyEntity" id-type="long" cascade="all">
<column name="tableName"/>
<column name="anyEntityId"/>
</any>
</class>
<class name="test.B"
table="B"
proxy="test.B">
<jcs-cache usage="read-write"/>
<id name="id" column="id" type="long">
<generator class="assigned">
</generator>
</id>
</class>
<class name="test.C"
table="C"
proxy="test.C">
<jcs-cache usage="read-write"/>
<id name="id" column="id" type="long">
<generator class="assigned">
</generator>
</id>
</class>
</hibernate-mapping>
Code:
A a=new A();
a.setId(new Long(0));
B b=new B();
b.setId(new Long(0));
a.setAnyEntity(b);
session.save(a);
the above code is ok,but the following code
Code:
a.setAnyEntity(session.load(B.class,new Long(0)));//Entity B[0] exists
session.save(a);
the value of column
a.tableName was set to be the class name of the
proxy instead of the class name of
test.B!
Does this mean that
anyEntity can not be set with a proxy?
And it seems that the cascade of any does not work.
Thanks.