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.  [ 1 post ] 
Author Message
 Post subject: Cascade property is None, by default. But delete is cascade!
PostPosted: Tue Apr 22, 2008 11:24 am 
Newbie

Joined: Tue Apr 15, 2008 5:12 am
Posts: 1
Hello!

NHibernate version:
2.0.0.Alpha1

Mapping documents:

Code:
<?xml version="1.0" encoding="utf-16"?>
<hibernate-mapping  auto-import="true" default-lazy="false" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:nhibernate-mapping-2.2">
  <class name="BusinessObjects.DomainObjects.Position, BusinessObjects" table="Position" schema="dbo" lazy="true">
    <id name="ID" access="property" column="ID" type="Int32" unsaved-value="0">
      <generator class="native">
      </generator>
    </id>
    <property name="Name" access="property" type="String">
      <column name="Name" not-null="true"/>
    </property>
    <many-to-one name="BusinessUnit" access="property" class="BusinessObjects.DomainObjects.BusinessUnit, BusinessObjects" column="BusinessUnitID" />
    <many-to-one name="PositionParent" access="property" class="BusinessObjects.DomainObjects.Position, BusinessObjects" column="ParentID" />
    <many-to-one name="Role" access="property" class="BusinessObjects.DomainObjects.Role, BusinessObjects" column="RoleID" />
    <many-to-one name="Team" access="property" class="BusinessObjects.DomainObjects.Team, BusinessObjects" column="TeamID" />
    <bag name="Assigments" access="property" table="Assigment" lazy="true">
      <key column="PositionID" />
      <one-to-many class="BusinessObjects.DomainObjects.Assigment, BusinessObjects" />
    </bag>
    <bag name="DisabledPositionsForProcesses" access="property" table="DisabledPositionsForProcess" lazy="true">
      <key column="PositionID" />
      <one-to-many class="BusinessObjects.DomainObjects.DisabledPositionsForProcess, BusinessObjects" />
    </bag>
    <bag name="Employees" access="property" table="Employee" lazy="true">
      <key column="PositionID" />
      <one-to-many class="BusinessObjects.DomainObjects.Employee, BusinessObjects" />
    </bag>
    <bag name="PositionChild" access="property" table="Position" lazy="true">
      <key column="ParentID" />
      <one-to-many class="BusinessObjects.DomainObjects.Position, BusinessObjects" />
    </bag>
    <bag name="SubProcessInfoes" access="property" table="SubProcessInfo" lazy="true">
      <key column="PositionID" />
      <one-to-many class="BusinessObjects.DomainObjects.SubProcessInfo, BusinessObjects" />
    </bag>
  </class>
</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():
session.Delete(entity);

Name and version of the database you are using:
MS SQL 2005



-----------

I hope that full mapping files aren't nessesary. I have an entity, when I try to delete it, I don't want to delete and updates relationsof it, but...

From SQL Profiler:
Code:
exec sp_executesql N'UPDATE dbo.Assigment SET PositionID = null WHERE PositionID = @p0',N'@p0 int',@p0=5
go
exec sp_executesql N'UPDATE dbo.DisabledPositionsForProcess SET PositionID = null WHERE PositionID = @p0',N'@p0 int',@p0=5
go
exec sp_executesql N'UPDATE dbo.Employee SET PositionID = null WHERE PositionID = @p0',N'@p0 int',@p0=5
go
exec sp_executesql N'UPDATE dbo.Position SET ParentID = null WHERE ParentID = @p0',N'@p0 int',@p0=5
go
exec sp_executesql N'UPDATE dbo.SubProcessInfo SET PositionID = null WHERE PositionID = @p0',N'@p0 int',@p0=5
go
exec sp_executesql N'DELETE FROM dbo.Position WHERE ID = @p0',N'@p0 int',@p0=5
go


Why does it work in a such way? How can I prevent it?


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

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.