Hi All,
I'm implementing a code as follow:
Code:
Model.Broker broker = new Model.Broker();
Model.Direccio direccio = new Model.Direccio("adreça","poblacio","codi_postal","provincia","pais");
broker.save(direccio);
broker.save(new Model.Client("codi","descripció", "alies", DateTime.Now, "nif", direccio));
but, I would like me this code:
Code:
Model.Broker broker = new Model.Broker();
Model.Direccio direccio = new Model.Direccio("adreça","poblacio","codi_postal","provincia","pais");
//broker.save(direccio);
broker.save(new Model.Client("codi","descripció", "alies", DateTime.Now, "nif", direccio));
In the second version I want that "direccio" object of a client is saved by default.
I imagine that it is possible altering XML mapping file.
XML Mapping file-->
Code:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="Model.Client, Broker" table="CLIENT">
<id name="Codi" column="CODI" type="String">
<generator class="assigned" />
</id>
<property name="Descripcio" column="DESCRIPCIO" type="String"/>
...
<one-to-one name="Direccio" class="Model.Direccio, Broker" constrained="true" cascade="all"/>
...
</class>
</hibernate-mapping>