Hibernate version: 1.2.0b3
Code between sessionFactory.openSession() and session.close():
Name and version of the database you are using: SQL Server 2005
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="PlaceTrakTNG.Business.Placement, PlaceTrakTNG.Business" table="Placement" >
<id name="placementID" column="PlacementID" access="field" type="Int32" unsaved-value="null">
<generator class="native"></generator>
</id>
<property name="FirstName" column="FirstName" type="String" access="property" not-null="true"></property>
<property name="LastName" column="LastName" type="String" access="property" not-null="true"></property>
<many-to-one name="Coordinator" class="PlaceTrakTNG.Business.User, PlaceTrakTNG.Business" column="CoordinatorUserID" access="property" fetch="join" ></many-to-one>
<many-to-one name="Specialist" class="PlaceTrakTNG.Business.User, PlaceTrakTNG.Business" column="SpecialistUserID" access="property" fetch="join" ></many-to-one>
<many-to-one name="ServiceRep" class="PlaceTrakTNG.Business.User, PlaceTrakTNG.Business" column="ServiceRepUserID" access="property" fetch="join" ></many-to-one>
<many-to-one name="CustomerServiceRep" class="PlaceTrakTNG.Business.User, PlaceTrakTNG.Business" column="CustomerServiceRepUserID" access="property" fetch="join" ></many-to-one>
</class>
</hibernate-mapping>
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="PlaceTrakTNG.Business.User, PlaceTrakTNG.Business" table="[User]" >
<id name="userID" column="UserID" type="Int32" access="field" unsaved-value="null">
<generator class="native" />
</id>
<version name="version" type="Int32" unsaved-value="null" access="field" />
<property name="LoginName" column="LoginName" type="Nullables.NHibernate.EmptyStringType, Nullables.NHibernate" access="property"></property>
<property name="Password" column="Password" type="Nullables.NHibernate.EmptyStringType, Nullables.NHibernate" access="property"></property>
<property name="FirstName" column="FirstName" type="Nullables.NHibernate.EmptyStringType, Nullables.NHibernate" access="property"></property>
<property name="LastName" column="LastName" type="Nullables.NHibernate.EmptyStringType, Nullables.NHibernate" access="property"></property>
<set name="CoordinatorPlacements" inverse="true" access="property" >
<key column="UserID" foreign-key="CoordinatorUserID"></key>
<one-to-many class="PlaceTrakTNG.Business.Placement, PlaceTrakTNG.Business" ></one-to-many>
</set>
<set name="RMPlacements" inverse="true" access="property" >
<key column="UserID" foreign-key="ServiceRepUserID"></key>
<one-to-many class="PlaceTrakTNG.Business.Placement, PlaceTrakTNG.Business" ></one-to-many>
</set>
<set name="CSRPlacements" inverse="true" access="property" >
<key column="UserID" foreign-key="CustomerServiceRepUserID"></key>
<one-to-many class="PlaceTrakTNG.Business.Placement, PlaceTrakTNG.Business" ></one-to-many>
</set>
<set name="ASPlacements" inverse="true" access="property" >
<key column="UserID" foreign-key="SpecialistUserID"></key>
<one-to-many class="PlaceTrakTNG.Business.Placement, PlaceTrakTNG.Business" ></one-to-many>
</set>
</class>
</hibernate-mapping>
When I call:
IList areaSpecialists = userDAO.GetPlacementRelatedAS();
IList csr = userDAO.GetPlacementRelatedCSR();
IList hc = userDAO.GetPlacementRelatedHC();
IList rms = userDAO.GetPlacementRelatedRM();
in my code-behind to get list of users who are related to Placement it works fine, however when I examine the log output nhibernate is generating updates after fetching the data:
007-02-16 10:20:18,320 [4136] INFO NHibernate.Loader.Loader [(null)] - select distinct u.* from [user] u join placement p on u.userID = p.CoordinatorUserID order by u.firstName, u.lastName
2007-02-16 10:20:18,320 [4136] DEBUG NHibernate.SQL [(null)] - select distinct u.* from [user] u join placement p on u.userID = p.CoordinatorUserID order by u.firstName, u.lastName
2007-02-16 10:20:18,351 [4136] DEBUG NHibernate.SQL [(null)] - UPDATE [User] SET version = @p0, LoginName = @p1, Password = @p2, FirstName = @p3, LastName = @p4, Title = @p5, Email = @p6, Phone = @p7, Fax = @p8, GroupID = @p9 WHERE UserID = @p10 AND version = @p11; @p0 = '8', @p1 = 'alove', @p2 = 'asdf ', @p3 = 'Amanda', @p4 = 'Love', @p5 = 'Account Coordinator', @p6 = '', @p7 = '', @p8 = '(5', @p9 = '21', @p10 = '10056', @p11 = '7'
2007-02-16 10:20:18,351 [4136] DEBUG NHibernate.SQL [(null)] - UPDATE [User] SET version = @p0, LoginName = @p1, Password = @p2, FirstName = @p3, LastName = @p4, Title = @p5, Email = @p6, Phone = @p7, Fax = @p8, GroupID = @p9 WHERE UserID = @p10 AND version = @p11; @p0 = '8', @p1 = 'aranly', @p2 = 'asdf ', @p3 = 'Amie', @p4 = 'Ranly', @p5 = 'Regional Sales Executive', @p6 = ', @p7 = '', @p8 = '', @p9 = '21', @p10 = '1000119', @p11 = '7'
2007-02-16 10:20:18,351 [4136] DEBUG NHibernate.SQL [(null)] - UPDATE [User] SET version = @p0, LoginName = @p1, Password = @p2, FirstName = @p3, LastName = @p4, Title = @p5, Email = @p6, Phone = @p7, Fax = @p8, GroupID = @p9 WHERE UserID = @p10 AND version = @p11; @p0 = '8', @p1 = '', @p2 = ' ', @p3 = 'Anne', @p4 = 'Parkhurst', @p5 = 'Placement Coordinator', @p6 = '', @p7 = '(800) ', @p8 = '', @p9 = '21', @p10 = '20079', @p11 = '7'
Anyone have any ideas why NHibernate is updating after fetching? I'm not doing _anything_ to modify the model objects, just fetching them to bind to dropdownlists. I even commented the databinding, and they are still being updated...
Also, this issue was also mentioned by someone else in post:
http://forum.hibernate.org/viewtopic.ph ... date+fetch
Thanks,
Rich C.