Hibernate version: 2.1.7
I have a class called Client which is mapped with a one-to-one relationship to a class called Budget. Basically, a Client can have a financial budget. This is a PK one-to-one mapping.
Everything executes fine, however, the Budget class is not cached when the Client is loaded, even though the Client object is cached. Both the Client and the Budget class have
<cache usage="read-write"/> defined.
I am using ehcache and the ehcache settings are correct. Even if they are not, the default cache settings should be used.
Should I be expecting this behaviour, or should one-to-one PK associations be cached?
Mapping documents:
Code:
<class name="Client" table="CLIENT">
<cache usage="read-write"/>
<id name="id" type="long" column="CLIENT_SEQ">
<generator class="sequence">
<param name="sequence">CLIENT_NUMBER_SEQ</param>
</generator>
</id>
<one-to-one name="budget" class="Budget"/>
</class>
<class name="Budget" table="CLIENT_BUDGET">
<cache usage="read-write"/>
<id name="id" column="CLIENT_SEQ">
<generator class="foreign">
<param name="property">id</param>
</generator>
</id>
</class>
Database tables: Code:
CLIENT
------
CLIENT_SEQ NUMBER NOT NULL
BUDGET
------
CLIENT_SEQ NUMBER NOT NULL
Thanks,
Ray.