A simple many-to-one mapping returns an 'empty' object (all properties are null) unless it was previously fetched in the session. Am I doing something wrong ?
Two entities CallBean & DChannelBean, both use Long for ID, all properties are access="field"
Failure Case:
Code:
c = (CallBean)s.get( CallBean.class, (Long)cid );
System.out.println( "Call "+c.id+" D "+c.dChannel.id+" should be "+did );
OUTPUT
Call 2 D null should be 1
Success Case:
Code:
d = (DChannelBean)s.get( DChannelBean.class, (Long)did );
c = (CallBean)s.get( CallBean.class, (Long)cid );
System.out.println( "Call "+c.id+" D "+c.dChannel.id+" should be "+did );
OUTPUT
Call 2 D 1 should be 1
-----------------
Here's the relevant xml..
Code:
<class name="CallBean" table="CALL">
<many-to-one name="dChannel"
column="D_CHANNEL_ID"
access="field"
class="DChannelBean"/>
Using Hibernate 3.0.3
Java 1.5.0_03
Tried on Postgres 8 and Oracle 10