Hi,
I am using an existing database, so I can't make significant changes to it.
THis is the User.hbm.xml file:
Code:
[i]<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="Infobase.Core.Domain.User, ePos.Core" table="TLPOSAddressLoginIDs">
<id name="LoginUid" column="EntryTLPOSAddressLoginID" type="Int32" >
<generator class="native" />
</id>
<many-to-one name="Details"
class="Infobase.Core.Domain.UserDetails, ePos.Core"
column="UniqueTLPOSAddress"
cascade="all" unique="true"/>
</class>
<class name="Infobase.Core.Domain.UserDetails, ePos.Core" table="TLPOSAddresses" dynamic-update="true">
<id name="Id" column="UniqueTLPOSAddress" type="Guid" >
<generator class="guid"></generator>
</id>
</class>
</hibernate-mapping>[/i]
Got my classes like this (made shorter to ommit irrelevant fields):
Code:
public class User {
private int loginUid;
private UserDetails details;
public virtual int LoginUid {
get { return loginUid; }
set { loginUid = value; }
}
public virtual UserDetails Details {
get {
if (details == null)
details = new UserDetails();
return details;
}
set { details = value;}
}
}
public class UserDetails {
private Guid id;
private User user;
public virtual Guid Id{
get { return id; }
set { id = value; }
}
}
When I create a new user and the details, it inserts the details first with a new generated guid, but in the table the guid is empty ('')
This is the debug from log4net
2009-03-17 09:48:34,640 [8] DEBUG NHibernate.Type.GuidType - binding '499eff7e-390c-411a-955d-29cdba6f557e' to parameter: 0
2009-03-17 09:48:34,640 [8] DEBUG NHibernate.SQL - INSERT INTO TLPOSAddresses (UniqueTLPOSAddress) VALUES (?); p0 = '499eff7e-390c-411a-955d-29cdba6f557e'
So that looks fine, but still an empty value is inserted into the database????
The database is Sql Anywhere 9.
I appreciate your help!
Linda