I'm not seeing the 2cd level cache hit for a List in a base class and I'm wondering if the subclasses inherit the many-to-one link setup in the base class. The object I start with is actually a subtype (not shown here) of the ManagedObject class. I can see the top level object (ManagedObject) hit in the cache but the children nodes associated with the object are retrieved each time from the database.
Here is the top level class.Code:
<?xml version="1.0"?>
<!-- $Id: ManagedObject.hbm.xml,v 1.13 2008/12/15 17:12:19 sudharshan Exp $ -->
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.adventnet.nms.topodb">
<class name="ManagedObject"
table="ManagedObject"
dynamic-insert="true"
dynamic-update="true"
select-before-update="true"
discriminator-value="ManagedObject">
<cache usage="read-write"/>
<id name="moid" column="MOID">
<generator class="increment"/>
</id>
<discriminator column="DISCRIMINATOR" type="string" length="30"/>
<natural-id>
<property name="name" type="string" column="NAME" not-null="true" length="255" />
</natural-id>
...skipped properties..
<list name="children" inverse="true" lazy="true" >
<key column="PARENTID" on-delete="cascade"/>
<list-index column="MOID"/>
<one-to-many class="ManagedObject" />
</list>
<many-to-one name="parentId" column="PARENTID" class="ManagedObject"/>
</class>
</hibernate-mapping>
Here is the subclass.
Does it need to also setup the many-to-one link or is doing it at the base class sufficient? Code:
<?xml version="1.0"?>
<!-- $Id: TopoObject.hbm.xml,v 1.3 2008/11/24 11:48:33 sudharshan Exp $ -->
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.adventnet.nms.topodb">
<subclass name="TopoObject" extends="ManagedObject"
dynamic-insert="true"
dynamic-update="true"
select-before-update="true"
discriminator-value="TopoObject">
<join table="TopoObject" fetch="select">
<key on-delete="cascade">
<column name="MOID"/>
</key>
<property
name="baseMibs"
type="string"
column="BASEMIBS"
length="100"/>
...skipped properties..
<property
name="writeCommunity"
type="string"
column="WRITECOMMUNITY"
length="100"/>
</join>
</subclass>
</hibernate-mapping>