Hibernate version: 2.1
Mapping documents:
AssetImpl.hbm.xml
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="com.acme.AssetImpl"
table="ACME_ASSET"
proxy="com.acme.AssetORInterface"
dynamic-update="true"
dynamic-insert="true"
>
<id
name="assetId"
column="ASSET_ID"
type="long"
>
<generator class="sequence">
<param name="sequence">ACME_ASSET_ID_SQ</param>
</generator>
</id>
<property
name="assetDescription"
type="string"
update="true"
insert="true"
access="property"
column="ASSET_DESCRIPTION"
not-null="false"
unique="false"
/>
<set
name="assetAttributesByAssetId"
table="ACME_ASSET_ATTRIBUTE"
lazy="true"
inverse="true"
cascade="none"
sort="unsorted"
>
<key
>
<column
name="ASSET_ID"
/>
</key>
<one-to-many
class="com.acme.AssetAttributeImpl"
/>
</set>
</class>
</hibernate-mapping>
AssetAttributeImpl.hbm.xml
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="com.acme.AssetAttributeImpl"
table="ACME_ASSET_ATTRIBUTE"
proxy="com.acme.AssetAttributeORInterface"
dynamic-update="true"
dynamic-insert="true"
>
<id
name="assetAttribute"
column="ASSET_ATTRIBUTE_ID"
type="long"
>
<generator class="sequence">
<param name="sequence">ACME_ASSET_ATTRIBUTE_ID_SQ</param>
</generator>
</id>
<many-to-one
name="assetId"
class="com.acme.AssetImpl"
cascade="none"
outer-join="auto"
update="true"
insert="true"
access="property"
column="ASSET_ID"
/>
<property
name="attributeName"
type="string"
update="true"
insert="true"
access="property"
column="ATTRIBUTE_NAME"
not-null="true"
unique="false"
/>
<property
name="attributeValue"
type="string"
update="true"
insert="true"
access="property"
column="ATTRIBUTE_VALUE"
not-null="false"
unique="false"
/>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():Code:
Asset asset = (Asset)session.load(AssetImpl.class, new Long(1L));
Set s = asset.getAssetAttributesByAssetId();
Iterator it = s.iterator();
while (it.hasNext()) {
AssetAttribute aa = (AssetAttribute)it.next();
System.out.println(aa.getClass().getName());
}
Interface Asset is the super-interface of AssetORInterface. AssetAttribute is the super-interface of AssetAttributeORInterface.
Full stack trace of any exception that occurs:
None
Name and version of the database you are using:
Oracle 9i
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
Hello,
From the code above, the classname printed is usually com.acme.AssetAttributeImpl. However, occasionally and randomly, I get com.acme.AssetAttributeORInterface$$EnhancerByCGLIB$$c8545bd8. It doesn't happen all the time.
I would appreciate it if someone can point out how and when CGLIB proxies the returned object.
Thanks a lot.