between 1.2.1 and NH2.0 there are more than 100.000 lines new/changed and was around than 2 years ago (note between NH.2.0 and NH2.1 there are another more than 100000 lines new changed). Probably: for assigned strategy there is a matter... in your case Arm is a related entity and what you are saving is the aggregate. We must know if the Arm instance need a INSERT or if it need an UPDATE. Using Load you are explicitly saying : don't worry, I'm pretty sure that the entity is there and I never changed its state in this case.
2009/10/30 Stefan Sedich <[email protected]> > Cool thanks Fabio I gathered this much, do you know what changed that > breaks this? Just out of curiosity really. > > > Cheers > Stefan > > On Fri, Oct 30, 2009 at 3:49 PM, Fabio Maulo <[email protected]> wrote: > >> yes, you should use Load instead a new obj with only id. >> >> 2009/10/29 Stefan Sedich <[email protected]> >> >> 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 >>> >>> >>> >> >> >> -- >> Fabio Maulo >> >> >> > > > -- > Stefan Sedich > Software Developer > http://weblogs.asp.net/stefansedich > > > > -- Fabio Maulo --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
