Well here is the deal. I have a Part entity, with it's codes and
descriptions, and a PartCost entity, with manufactoring costs. The
relationship is one to one, but for organizational reasons they had to
be separated (not all parts have this cost).
The thing is: On load, it's perfect. it loads the partentity and the
PartCost Entity, and on update works well too, because non of the part
area is altered, only the cost.
The thing is on creating a new instance of the Cost entity, I want it
to create a new record on the PartCost table, fetching the PartID from
the Part Table, while the user inputs the Code value of the part. But
with my mapping, it creates a new record on the Part table too, so I
assume on the update it tries to update it too, but since there are no
changes i didn't noticed it.
do I have to separate them and load them individually? or is there a
way to use some kind of left join (loads the part and if there is a
cost loads it too) so when i create a new instance of PartCost, i can
assign it the value of the ID of the Part that was already loaded?
Here is the current mapping:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="Part" table ="Tbl_Part">
<id name="ID" column="PartID_PK" type="integer">
<generator class="identity" />
</id>
<property name="Code" column="PartCode" type="string" length="50" /
>
<property name="Type" column="PartType" type="string" length="20"/
>
<property name="Description" column="Descrip" type="string"
length="50" />
<property name="DescriptionGE" column="DescripUK" type="string"
length="50" />
<property name="DescriptionUK" column="DescripGE" type="string"
length="50" />
<joined-subclass name="PartCost" table="Tbl_PartCost">
<key column="PartID_FK"/>
<property name="LabourID" column="LabourID_FK" type="integer"/>
<property name="LabourTime" column="TotalTime" type="integer"/>
<property name="RawMaterial" column="TotalRM" type="Double"/>
<property name="LabourCost" column="TotalLabour" type="Double"/
>
<property name="FixedCost" column="TotalFixedCost"
type="Double"/>
<property name="VariableCost" column="TotalVariableCost"
type="Double"/>
</joined-subclass>
</class>
</hibernate-mapping>
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en.