Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 1.2.1.4000
Mapping documents:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="IranWin.Core.DomainClasses" assembly="IranWin.Core" default-lazy="false" >
<class name="User" table="Users" >
<id column="Id" name="Id" unsaved-value="0">
<generator class="native" />
</id>
<property name="Firstname" not-null="true" />
<property name="Lastname" not-null="true" />
<property name="Birthdate" not-null="true" />
<property name="Email" not-null="true" />
<property name="Phone" not-null="true" />
<property name="MobilePhone" not-null="true" />
<property name="Address" not-null="true" />
<property name="Username" not-null="true" />
<property name="Password" not-null="true" />
<property name="RegisterDate" not-null="true" />
<property name="Balance" not-null="true" />
<property name="Score" not-null="true" />
<property name="UserStatus" not-null="true" />
<property name="UserLevel" not-null="true" />
<property name="LastLoginDate" not-null="false" />
<bag name="Transactions" cascade="all" lazy="true">
<key column="UserId" />
<one-to-many class="Transaction" />
</bag>
<bag name="Accounts" cascade="all" lazy="true" >
<key column="UserId" />
<one-to-many class="BankAccount" />
</bag>
<many-to-one name="Referer" column="RefererId" cascade="all" />
</class>
</hibernate-mapping>
Name and version of the database you are using: MS SQL Server Express 2005
the problem is when i want to update the user i should load both Transactions and Accounts collection first , and then i can use SaveOrUpdate, otherwise it throws exception that Hibernate cannot work with 2 open session !
how can i solve this problem ?