Just curious about the below:
I have the below mappings:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="Common"
assembly="Common">
<class name="Arm" table="Arms">
<id name="Id" column="Id">
<generator class="assigned" />
</id>
<property name="Desc" type="String" not-null="true" />
</class>
</hibernate-mapping>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="Common"
assembly="Common">
<class name="Person" table="People">
<id name="Id" column="Id">
<generator class="assigned" />
</id>
<property name="Name" type="String" not-null="true" />
<many-to-one name="Arm" column="ArmId" />
</class>
</hibernate-mapping>
I run the following with NH 1.2 and get:
var arm = new Arm() {Id = 123};
var person = new Person() {Id = 1, Name = "Bob", Arm = arm};
Session.Save(person);
Session.Flush();
RESULT: NHibernate: INSERT INTO People (Name, ArmId, Id) VALUES (@p0,
@p1, @p2); @p0 = 'Bob', @p1 = '123', @p2 = '1'
Running with NH 2.1:
NHibernate: SELECT arm_.Id, arm_.Desc as Desc0_ FROM Arms arm_ WHERE
arm_....@p0;@p0
= 123
NHibernate: INSERT INTO People (Name, ArmId, Id) VALUES (@p0, @p1,
@p2);@p0 = 'Bob', @p1 = NULL, @p2 = 1
NHibernate: UPDATE People SET Name = @p0, ArmId = @p1 WHERE Id = @p2;@p0
= 'Bob', @p1 = 123, @p2 = 1
Now with NH 2.1 it selects the arm back and as it is null it sets the armid
to null, but with NH 1.2 it updates with the ID in my transient object.
Now what I want to understand is what the difference is, mostly the issue is
trying to convert and old NH 1.2 app to 2.1 and having simmilar issues.
I am aware that if in 2.1 if I use:
var arm = Session.Load<Arm>(123);
var person = new Person() { Id = 1, Name = "Bob", Arm = arm };
Then it does as I expect, is it a case I need to use the above to do what I
need?
Cheers
Stefan
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---