Hi there,
I'm having a problem with many-to-one proxy. The class is lazy loading and a proxy is being returned, however, all the proxy values including the identifier are never initialised when I request the proxy object. I looked at the proxy in a debugger and it looks like:
Type: CProxyTypeCurrencyInfodal_INHibernateProxy1
Id: 0
Name: null
Have I configured something incorrectly? I thought it might be to do with unsaved-value or the definition of my Equals or hashcode, but I've written them using business key equality and using the class properties instead of the class field values as described in 'Hibernate in Action' ... still no joy :(
How do I get the proxy to initialise when values are requested?
Any help appreciated,
Ronan
My class mappings
Code:
///////////////////////////////////////////
// CurrencyInfo mapping
<class
name="com.luzern.ccc.dal.CurrencyInfo, CCCDbLib"
table="tblSalesCurrency"
lazy="true"
>
<id
name="Id"
type="Decimal"
column="CurrencyID"
unsaved-value="0"
>
<generator class="identity" />
</id>
<property
name="Name"
type="System.String"
column="CurrencyName"
length="50"
/>
<set name="SalesChannels" table="tblSalesChannel" cascade="all-delete-orphan" lazy="true">
<key>
<column name="CurrencyID"/>
</key>
<one-to-many class="com.luzern.ccc.dal.SalesChannel, CCCDbLib"/>
</set>
</class>
</hibernate-mapping>
///////////////////////////////////////////
// End CurrencyInfo mapping
///////////////////////////////////////////
///////////////////////////////////////////
// Start SalesChannel mapping
///////////////////////////////////////////
<class
name="com.luzern.ccc.dal.SalesChannel, CCCDbLib"
table="tblSalesChannel"
lazy="true"
>
<id
name="Id"
type="Decimal"
column="SalesChannelId"
unsaved-value="-1"
>
<generator class="identity" />
</id>
<many-to-one
name="CurrencyInfo"
class="com.luzern.ccc.dal.CurrencyInfo, CCCDbLib"
column="Currency"
not-null="true"/>
</class>
</hibernate-mapping>
///////////////////////////////////////////
// End SalesChannel mapping
///////////////////////////////////////////
[/b]