-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: SQL insert, update or delete failed (expected affected...)
PostPosted: Wed Sep 20, 2006 12:22 am 
Newbie

Joined: Wed Sep 20, 2006 12:12 am
Posts: 1
Hi !
Sorry, if i am asking about a trivial problem.
I tried to cascade update parent/child elements, il got the message below:
SQL insert, update or delete failed (expected affected row count: 1, actual affected row count: 0). Possible causes: the row was modified or deleted by another user, or a trigger is reporting misleading row count.

I don't know if it's a facility problem, or anything else.

Thanks in advance for your help.

Code:
       
        Department dept = session.Load(typeof(Department), 1)) as Department;

        Employee emp = new Employee();
        emp.DeptDepartment = dept;
        emp.Name = "my name";
        emp.Sex = 1;

        dept.EmployeesDept.Add(emp);

        session.Save(dept);


Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
  <class name="Com.Benday.BugTracker.Business.Department, Com.Benday.BugTracker.Business" table="Department">
    <id name="Id" type="Int32" unsaved-value="null">
      <column name="Id" length="4" sql-type="int" not-null="true" unique="true" index="PK_Department"/>
      <generator class="native" />
    </id>
    <property name="Name" type="String">
      <column name="Name" length="50" sql-type="nvarchar" not-null="true"/>
    </property>
    <bag name="EmployeesDept" inverse="true" lazy="true" cascade="all">
      <key column="DeptId"/>
      <one-to-many class="Com.Benday.BugTracker.Business.Employee, Com.Benday.BugTracker.Business"/>
    </bag>
  </class>
</hibernate-mapping>


Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
  <class name="Com.Benday.BugTracker.Business.Employee, Com.Benday.BugTracker.Business" table="Employee">
    <id name="Id" type="Int32" unsaved-value="null">
      <column name="Id" length="4" sql-type="int" not-null="true" unique="true" index="PK_Employee"/>
      <generator class="native" />
    </id>
    <property name="Name" type="String">
      <column name="name" length="50" sql-type="nvarchar" not-null="true"/>
    </property>
    <property name="Sex" type="Single">
      <column name="sex" length="4" sql-type="real" not-null="true"/>
    </property>
    <many-to-one name="DeptDepartment" class="Com.Benday.BugTracker.Business.Department, Com.Benday.BugTracker.Business">
      <column name="DeptId" length="4" sql-type="int" not-null="true"/>
    </many-to-one>
  </class>
</hibernate-mapping>


Tony


Top
 Profile  
 
 Post subject: Re: SQL insert, update or delete failed (expected affected..
PostPosted: Wed Sep 20, 2006 3:08 am 
Beginner
Beginner

Joined: Wed Aug 03, 2005 8:06 am
Posts: 40
Location: Netherlands
You should do session.Save(emp), not session.Save(dept).


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.