This list is for discussion re: the development *of* NHibernate rather than development *with* NHibernate.
Please direct your post to the NHUSERS list here: http://groups.google.com/group/nhusers Regards, Steve Bohlen [email protected] http://blog.unhandled-exceptions.com http://twitter.com/sbohlen On Sun, Jan 23, 2011 at 8:40 AM, Nima <[email protected]> wrote: > I have a one-to-one relationship between a Person class and an > Employee. I expect the INSERT to cascade from the Person to the > Employee. However, this does not happen. I've tried cascade='all' and > cascade='save-update' on one-to-one relationship element, but it > didn't work. The source code is available on: http://bit.ly/gNlAWr > > The structures of the my objects are as follows: > > public class Employee > { > private int _personID; > private string _payrollNo; > private int _holidays; > private Person _personInstance; > } > > public class Person > { > private int _personID; > private string _surname; > private string _forename; > private int _age; > private Employee _employeeInstance; > } > > Mapping files shown below: > > <?xml version="1.0" encoding="utf-8" ?> > <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"> > <class name="Employee, Employee.DAL" table="`Employee`" > > <id name="PersonID" column="`PersonId`"> > <generator class="foreign"> > <param name="property" >PersonInstance</param> > </generator> > </id> > <property type="string" length="30" name="PayRollNo" > column="`PayRollNo`" /> > <property type="int" name="Holidays" column="`Holidays`" /> > <one-to-one name="PersonInstance" class="Person, Employee.DAL" > constrained="true" /> > </class> > </hibernate-mapping> > > <?xml version="1.0" encoding="utf-8" ?> > <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"> > <class name="Person, Employee.DAL" table="`Person`" > > <id name="PersonID" column="`PersonId`" type="int"> > <generator class="native" /> > </id> > <property type="string" name="Forename" column="`Forename`" /> > <property type="string" name="Surname" column="`Surname`" /> > <property type="int" name="Age" column="`Age`" /> > <one-to-one name="EmployeeInstance" cascade="all" > class="Employee,Employee.DAL" /> > </class> > </hibernate-mapping> > > > >
