-->
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.  [ 8 posts ] 
Author Message
 Post subject: One to many problem
PostPosted: Fri Jan 20, 2006 6:46 am 
Newbie

Joined: Mon Jan 09, 2006 4:57 am
Posts: 18
NHibernate version: 1.0.2.0

Mapping documents:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
  <class name="BugProject.ModelClasses.Model, BugProject" table="T_Model_Master">
    <id name="Id" column="Model_ID" type="Int32" unsaved-value="null">
      <generator class="identity" />
    </id>

    <property name="Name" column="Model_Name" type="String" length="50" />
    <property name="Info" column="Model_Info" type="String" length="255" />
    <property name="Type" column="Model_Type" type="Int32" />

    <set name="Lines" cascade="all-delete-orphan" lazy="false" inverse="true">
      <key column="Model_Id" />
      <one-to-many class="BugProject.ModelClasses.Line, BugProject" />
    </set>
   
  </class>
</hibernate-mapping>

Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
  <class name="BugProject.ModelClasses.Line, BugProject" table="T_Logical_Rail">
    <id name="Id" column="Path_ID" type="Int32">
      <generator class="identity" />
    </id>

    <component name="StartPoint" class="BugProject.ModelClasses.Point, BugProject">
      <property name="X" column="X0_Coord" type="Int32" />
      <property name="Y" column="Y0_Coord" type="Int32" />
    </component>
    <component name="EndPoint" class="BugProject.ModelClasses.Point, BugProject">
      <property name="X" column="X1_Coord" type="Int32" />
      <property name="Y" column="Y1_Coord" type="Int32" />
    </component>

    <set name="Points" cascade="all-delete-orphan" lazy="false" inverse="true">
      <key column="Path_ID" />
      <one-to-many class="BugProject.ModelClasses.RailPoint, BugProject" />
    </set>
   
    <many-to-one name="Model" column="Model_Id" not-null="true" />
  </class>
</hibernate-mapping>

Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
  <class name="BugProject.ModelClasses.RailPoint, BugProject" table="T_Logical_Rail_Point">
    <id name="Id" column="Point_ID" type="Int32">
      <generator class="identity" />
    </id>

    <component name="Point" class="BugProject.ModelClasses.Point, BugProject">
      <property name="X" column="X_Coord" type="Int32" />
      <property name="Y" column="Y_Coord" type="Int32" />
    </component>

    <many-to-one name="Line" column="Path_ID" not-null="true" />
  </class>
</hibernate-mapping>


Model class code
Code:
using System;

using Iesi.Collections;

namespace BugProject.ModelClasses
{

    public class Model
    {

        private int id;
        private string name;
        private string info;
        private int type;
        private ISet lines;

        public int Id
        {
            get { return id; }
            set { id = value; }
        }

        public string Name
        {
            get { return name; }
            set { name = value; }
        }

        public string Info
        {
            get { return info; }
            set { info = value; }
        }

        public int Type
        {
            get { return type; }
            set { type = value; }
        }

        public ISet Lines
        {
            get { return lines; }
            set { lines = value; }
        }

    }

}

Code:
using Iesi.Collections;

namespace BugProject.ModelClasses
{

    public class Line
    {

        private int id;
        private Point startPoint;
        private Point endPoint;
        private ISet points;

        private Model model;

        public Line() { }

        public Line(Point StartPoint, Point EndPoint)
        {
            this.StartPoint = StartPoint;
            this.EndPoint = EndPoint;
        }

        public int Id
        {
            get { return id; }
            set { id = value; }
        }

        public Point StartPoint
        {
            get { return startPoint; }
            set { startPoint = value; }
        }

        public Point EndPoint
        {
            get { return endPoint; }
            set { endPoint = value; }
        }

        public ISet Points
        {
            get { return points;  }
            set { points = value; }
        }

        public Model Model
        {
            get { return model; }
            set { model = value; }
        }

    }

}

Code:
namespace BugProject.ModelClasses
{
    public class RailPoint
    {

        private int id;
        private Point point;

        private Line line;

        public int Id
        {
            get { return id; }
            set { id = value; }
        }
       
        public Point Point
        {
            get { return point; }
            set { point = value; }
        }

        public Line Line
        {
            get { return line; }
            set { line = value; }
        }

        public RailPoint() { }

        public RailPoint(int X, int Y)
        {
            point = new Point(X, Y);
        }

    }
}


Code between sessionFactory.openSession() and session.close():
Code:
            Model model = new Model();

            model.Name = "Bug model";
            model.Info = "Bug model";
            model.Type = 1;

            ListSet lines = new ListSet();

            // Create line1
            Line line1 = new Line(new BugProject.ModelClasses.Point(1, 10), new BugProject.ModelClasses.Point(1, 20));
            line1.Model = model;
            line1.Points = new ListSet();

            lines.Add(line1);

            // Add rail points to line1
            for (int i = 10; i <= 20; i++)
            {
                RailPoint railPoint = new RailPoint(1, i);
                railPoint.Line = line1;

                line1.Points.Add(railPoint);
            }

            // Create line2
            Line line2 = new Line(new BugProject.ModelClasses.Point(10, 10), new BugProject.ModelClasses.Point(20, 20));
            line2.Model = model;

            lines.Add(line2);

            model.Lines = lines;

            ITransaction tx = session.BeginTransaction();

            session.Save(model);
            tx.Commit();


Full stack trace of any exception that occurs:
Code:
NHibernate.ADOException was unhandled
  Message="could not insert: [BugProject.ModelClasses.RailPoint]"
  Source="NHibernate"
  StackTrace:
       at NHibernate.Persister.EntityPersister.Insert(Object[] fields, Boolean[] notNull, SqlString sql, Object obj, ISessionImplementor session)
       at NHibernate.Persister.EntityPersister.Insert(Object[] fields, Object obj, ISessionImplementor session)
       at NHibernate.Impl.ScheduledIdentityInsertion.Execute()
       at NHibernate.Impl.SessionImpl.Execute(IExecutable executable)
       at NHibernate.Impl.SessionImpl.DoSave(Object theObj, Key key, IClassPersister persister, Boolean replicate, Boolean useIdentityColumn, CascadingAction cascadeAction, Object anything)
       at NHibernate.Impl.SessionImpl.DoSave(Object obj, Object id, IClassPersister persister, Boolean useIdentityColumn, CascadingAction cascadeAction, Object anything)
       at NHibernate.Impl.SessionImpl.SaveWithGeneratedIdentifier(Object obj, CascadingAction action, Object anything)
       at NHibernate.Impl.SessionImpl.Save(Object obj)
       at NHibernate.Impl.SessionImpl.SaveOrUpdate(Object obj)
       at NHibernate.Engine.Cascades.CascadingAction.ActionSaveUpdateClass.Cascade(ISessionImplementor session, Object child, Object anything)
       at NHibernate.Engine.Cascades.Cascade(ISessionImplementor session, Object child, IType type, CascadingAction action, CascadeStyle style, CascadePoint cascadeTo, Object anything)
       at NHibernate.Engine.Cascades.CascadeCollection(CascadingAction action, CascadeStyle style, PersistentCollectionType collectionType, IType elemType, Object child, CascadePoint cascadeVia, ISessionImplementor session, Object anything)
       at NHibernate.Engine.Cascades.Cascade(ISessionImplementor session, Object child, IType type, CascadingAction action, CascadeStyle style, CascadePoint cascadeTo, Object anything)
       at NHibernate.Engine.Cascades.Cascade(ISessionImplementor session, IClassPersister persister, Object parent, CascadingAction action, CascadePoint cascadeTo, Object anything)
       at NHibernate.Impl.SessionImpl.DoSave(Object theObj, Key key, IClassPersister persister, Boolean replicate, Boolean useIdentityColumn, CascadingAction cascadeAction, Object anything)
       at NHibernate.Impl.SessionImpl.DoSave(Object obj, Object id, IClassPersister persister, Boolean useIdentityColumn, CascadingAction cascadeAction, Object anything)
       at NHibernate.Impl.SessionImpl.SaveWithGeneratedIdentifier(Object obj, CascadingAction action, Object anything)
       at NHibernate.Impl.SessionImpl.Save(Object obj)
       at NHibernate.Impl.SessionImpl.SaveOrUpdate(Object obj)
       at NHibernate.Engine.Cascades.CascadingAction.ActionSaveUpdateClass.Cascade(ISessionImplementor session, Object child, Object anything)
       at NHibernate.Engine.Cascades.Cascade(ISessionImplementor session, Object child, IType type, CascadingAction action, CascadeStyle style, CascadePoint cascadeTo, Object anything)
       at NHibernate.Engine.Cascades.CascadeCollection(CascadingAction action, CascadeStyle style, PersistentCollectionType collectionType, IType elemType, Object child, CascadePoint cascadeVia, ISessionImplementor session, Object anything)
       at NHibernate.Engine.Cascades.Cascade(ISessionImplementor session, Object child, IType type, CascadingAction action, CascadeStyle style, CascadePoint cascadeTo, Object anything)
       at NHibernate.Engine.Cascades.Cascade(ISessionImplementor session, IClassPersister persister, Object parent, CascadingAction action, CascadePoint cascadeTo, Object anything)
       at NHibernate.Impl.SessionImpl.DoSave(Object theObj, Key key, IClassPersister persister, Boolean replicate, Boolean useIdentityColumn, CascadingAction cascadeAction, Object anything)
       at NHibernate.Impl.SessionImpl.DoSave(Object obj, Object id, IClassPersister persister, Boolean useIdentityColumn, CascadingAction cascadeAction, Object anything)
       at NHibernate.Impl.SessionImpl.SaveWithGeneratedIdentifier(Object obj, CascadingAction action, Object anything)
       at NHibernate.Impl.SessionImpl.Save(Object obj)
       at BugProject.UI.Test.btnCreate_Click(Object sender, EventArgs e) in D:\_Works\_NET\CSharp\BugProject\UI\Test.cs:line 89
       at System.Windows.Forms.Control.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ButtonBase.WndProc(Message& m)
       at System.Windows.Forms.Button.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.Run(Form mainForm)
       at BugProject.Program.Main() in D:\_Works\_NET\CSharp\BugProject\Program.cs:line 17
       at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()


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

Model

Image

I can not insert RailPoint into database 'cause Model_ID is null. How can I solve it? Thanks a lot!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 20, 2006 8:32 am 
Newbie

Joined: Mon Jan 09, 2006 4:57 am
Posts: 18
You can try out my source code

Source code

Please help me! Thanks![/url]


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 20, 2006 9:23 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Try enabling SQL logging and check the statements that NH attempts to execute.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 20, 2006 9:41 am 
Newbie

Joined: Mon Jan 09, 2006 4:57 am
Posts: 18
sergey wrote:
Try enabling SQL logging and check the statements that NH attempts to execute.


It's full stack trace;

Code:
2006-01-20 20:36:42,978 [2792] INFO  NHibernate.Cfg.Environment [(null)] <(null)> - NHibernate 1.0.1.0
2006-01-20 20:36:43,008 [2792] INFO  NHibernate.Cfg.Environment [(null)] <(null)> - Using reflection optimizer
2006-01-20 20:36:43,008 [2792] INFO  NHibernate.Cfg.Configuration [(null)] <(null)> - Searching for mapped documents in assembly: BugProject
2006-01-20 20:36:43,018 [2792] INFO  NHibernate.Cfg.Configuration [(null)] <(null)> - Found mapping documents in assembly: BugProject.MappingFiles.RailPoint.hbm.xml
2006-01-20 20:36:43,069 [2792] INFO  NHibernate.Dialect.Dialect [(null)] <(null)> - Using dialect: NHibernate.Dialect.MsSql2000Dialect
2006-01-20 20:36:43,109 [2792] INFO  NHibernate.Cfg.Binder [(null)] <(null)> - Mapping class: BugProject.ModelClasses.RailPoint -> T_Logical_Rail_Point
2006-01-20 20:36:43,139 [2792] DEBUG NHibernate.Cfg.Binder [(null)] <(null)> - Mapped property: Id -> Point_ID, type: Int32
2006-01-20 20:36:43,169 [2792] DEBUG NHibernate.Cfg.Binder [(null)] <(null)> - Mapped property: X -> X_Coord, type: Int32
2006-01-20 20:36:43,169 [2792] DEBUG NHibernate.Cfg.Binder [(null)] <(null)> - Mapped property: Y -> Y_Coord, type: Int32
2006-01-20 20:36:43,189 [2792] DEBUG NHibernate.Persister.GetSetHelperFactory [(null)] <(null)> - Init compiler for class BugProject.ModelClasses.Point
2006-01-20 20:36:43,189 [2792] DEBUG NHibernate.Persister.GetSetHelperFactory [(null)] <(null)> - Adding referenced assembly D:\_Works\_NET\CSharp\BugProject\bin\Debug\NHibernate.dll
2006-01-20 20:36:43,189 [2792] DEBUG NHibernate.Persister.GetSetHelperFactory [(null)] <(null)> - Adding referenced assembly D:\_Works\_NET\CSharp\BugProject\bin\Debug\BugProject.exe
2006-01-20 20:36:43,199 [2792] DEBUG NHibernate.Persister.GetSetHelperFactory [(null)] <(null)> - Adding referenced assembly C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll
2006-01-20 20:36:43,399 [2792] DEBUG NHibernate.Persister.GetSetHelperFactory [(null)] <(null)> - Compiled ok:
using System;
using NHibernate.Property;
namespace NHibernate.Persister {
public class GetSetHelper_BugProject_ModelClasses_Point : IGetSetHelper {
  ISetter[] setters;
  IGetter[] getters;
  public GetSetHelper_BugProject_ModelClasses_Point(ISetter[] setters, IGetter[] getters) {
    this.setters = setters;
    this.getters = getters;
  }
public void SetPropertyValues(object obj, object[] values) {
  BugProject.ModelClasses.Point t = (BugProject.ModelClasses.Point)obj;
  t.X = values[0] == null ? new System.Int32() : (System.Int32)values[0];
  t.Y = values[1] == null ? new System.Int32() : (System.Int32)values[1];
}
public object[] GetPropertyValues(object obj) {
  BugProject.ModelClasses.Point t = (BugProject.ModelClasses.Point)obj;
  object[] ret = new object[2];
  ret[0] = t.X;
  ret[1] = t.Y;
  return ret;
}
}
}

2006-01-20 20:36:43,399 [2792] DEBUG NHibernate.Cfg.Binder [(null)] <(null)> - Mapped property: Point -> X_Coord, Y_Coord, type: Point
2006-01-20 20:36:43,409 [2792] DEBUG NHibernate.Cfg.Binder [(null)] <(null)> - Mapped property: Line -> Path_ID, type: Line
2006-01-20 20:36:43,409 [2792] INFO  NHibernate.Cfg.Configuration [(null)] <(null)> - Found mapping documents in assembly: BugProject.MappingFiles.Line.hbm.xml
2006-01-20 20:36:43,409 [2792] INFO  NHibernate.Dialect.Dialect [(null)] <(null)> - Using dialect: NHibernate.Dialect.MsSql2000Dialect
2006-01-20 20:36:43,409 [2792] INFO  NHibernate.Cfg.Binder [(null)] <(null)> - Mapping class: BugProject.ModelClasses.Line -> T_Logical_Rail
2006-01-20 20:36:43,409 [2792] DEBUG NHibernate.Cfg.Binder [(null)] <(null)> - Mapped property: Id -> Path_ID, type: Int32
2006-01-20 20:36:43,409 [2792] DEBUG NHibernate.Cfg.Binder [(null)] <(null)> - Mapped property: X -> X0_Coord, type: Int32
2006-01-20 20:36:43,409 [2792] DEBUG NHibernate.Cfg.Binder [(null)] <(null)> - Mapped property: Y -> Y0_Coord, type: Int32
2006-01-20 20:36:43,409 [2792] DEBUG NHibernate.Persister.GetSetHelperFactory [(null)] <(null)> - Init compiler for class BugProject.ModelClasses.Point
2006-01-20 20:36:43,409 [2792] DEBUG NHibernate.Persister.GetSetHelperFactory [(null)] <(null)> - Adding referenced assembly D:\_Works\_NET\CSharp\BugProject\bin\Debug\NHibernate.dll
2006-01-20 20:36:43,409 [2792] DEBUG NHibernate.Persister.GetSetHelperFactory [(null)] <(null)> - Adding referenced assembly D:\_Works\_NET\CSharp\BugProject\bin\Debug\BugProject.exe
2006-01-20 20:36:43,409 [2792] DEBUG NHibernate.Persister.GetSetHelperFactory [(null)] <(null)> - Adding referenced assembly C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll
2006-01-20 20:36:43,569 [2792] DEBUG NHibernate.Persister.GetSetHelperFactory [(null)] <(null)> - Compiled ok:
using System;
using NHibernate.Property;
namespace NHibernate.Persister {
public class GetSetHelper_BugProject_ModelClasses_Point : IGetSetHelper {
  ISetter[] setters;
  IGetter[] getters;
  public GetSetHelper_BugProject_ModelClasses_Point(ISetter[] setters, IGetter[] getters) {
    this.setters = setters;
    this.getters = getters;
  }
public void SetPropertyValues(object obj, object[] values) {
  BugProject.ModelClasses.Point t = (BugProject.ModelClasses.Point)obj;
  t.X = values[0] == null ? new System.Int32() : (System.Int32)values[0];
  t.Y = values[1] == null ? new System.Int32() : (System.Int32)values[1];
}
public object[] GetPropertyValues(object obj) {
  BugProject.ModelClasses.Point t = (BugProject.ModelClasses.Point)obj;
  object[] ret = new object[2];
  ret[0] = t.X;
  ret[1] = t.Y;
  return ret;
}
}
}

2006-01-20 20:36:43,569 [2792] DEBUG NHibernate.Cfg.Binder [(null)] <(null)> - Mapped property: StartPoint -> X0_Coord, Y0_Coord, type: Point
2006-01-20 20:36:43,569 [2792] DEBUG NHibernate.Cfg.Binder [(null)] <(null)> - Mapped property: X -> X1_Coord, type: Int32
2006-01-20 20:36:43,569 [2792] DEBUG NHibernate.Cfg.Binder [(null)] <(null)> - Mapped property: Y -> Y1_Coord, type: Int32
2006-01-20 20:36:43,569 [2792] DEBUG NHibernate.Persister.GetSetHelperFactory [(null)] <(null)> - Init compiler for class BugProject.ModelClasses.Point
2006-01-20 20:36:43,569 [2792] DEBUG NHibernate.Persister.GetSetHelperFactory [(null)] <(null)> - Adding referenced assembly D:\_Works\_NET\CSharp\BugProject\bin\Debug\NHibernate.dll
2006-01-20 20:36:43,569 [2792] DEBUG NHibernate.Persister.GetSetHelperFactory [(null)] <(null)> - Adding referenced assembly D:\_Works\_NET\CSharp\BugProject\bin\Debug\BugProject.exe
2006-01-20 20:36:43,569 [2792] DEBUG NHibernate.Persister.GetSetHelperFactory [(null)] <(null)> - Adding referenced assembly C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll
2006-01-20 20:36:43,729 [2792] DEBUG NHibernate.Persister.GetSetHelperFactory [(null)] <(null)> - Compiled ok:
using System;
using NHibernate.Property;
namespace NHibernate.Persister {
public class GetSetHelper_BugProject_ModelClasses_Point : IGetSetHelper {
  ISetter[] setters;
  IGetter[] getters;
  public GetSetHelper_BugProject_ModelClasses_Point(ISetter[] setters, IGetter[] getters) {
    this.setters = setters;
    this.getters = getters;
  }
public void SetPropertyValues(object obj, object[] values) {
  BugProject.ModelClasses.Point t = (BugProject.ModelClasses.Point)obj;
  t.X = values[0] == null ? new System.Int32() : (System.Int32)values[0];
  t.Y = values[1] == null ? new System.Int32() : (System.Int32)values[1];
}
public object[] GetPropertyValues(object obj) {
  BugProject.ModelClasses.Point t = (BugProject.ModelClasses.Point)obj;
  object[] ret = new object[2];
  ret[0] = t.X;
  ret[1] = t.Y;
  return ret;
}
}
}

2006-01-20 20:36:43,739 [2792] DEBUG NHibernate.Cfg.Binder [(null)] <(null)> - Mapped property: EndPoint -> X1_Coord, Y1_Coord, type: Point
2006-01-20 20:36:43,760 [2792] DEBUG NHibernate.Cfg.Binder [(null)] <(null)> - Mapped property: Points, type: ISet
2006-01-20 20:36:43,760 [2792] DEBUG NHibernate.Cfg.Binder [(null)] <(null)> - Mapped property: Model -> Model_Id, type: Model
2006-01-20 20:36:43,760 [2792] INFO  NHibernate.Cfg.Configuration [(null)] <(null)> - Found mapping documents in assembly: BugProject.MappingFiles.Model.hbm.xml
2006-01-20 20:36:43,760 [2792] INFO  NHibernate.Dialect.Dialect [(null)] <(null)> - Using dialect: NHibernate.Dialect.MsSql2000Dialect
2006-01-20 20:36:43,760 [2792] INFO  NHibernate.Cfg.Binder [(null)] <(null)> - Mapping class: BugProject.ModelClasses.Model -> T_Model_Master
2006-01-20 20:36:43,760 [2792] DEBUG NHibernate.Cfg.Binder [(null)] <(null)> - Mapped property: Id -> Model_ID, type: Int32
2006-01-20 20:36:43,760 [2792] DEBUG NHibernate.Cfg.Binder [(null)] <(null)> - Mapped property: Name -> Model_Name, type: String
2006-01-20 20:36:43,760 [2792] DEBUG NHibernate.Cfg.Binder [(null)] <(null)> - Mapped property: Info -> Model_Info, type: String
2006-01-20 20:36:43,760 [2792] DEBUG NHibernate.Cfg.Binder [(null)] <(null)> - Mapped property: Type -> Model_Type, type: Int32
2006-01-20 20:36:43,760 [2792] DEBUG NHibernate.Cfg.Binder [(null)] <(null)> - Mapped property: Lines, type: ISet
2006-01-20 20:36:43,770 [2792] INFO  NHibernate.Cfg.Configuration [(null)] <(null)> - processing one-to-many association mappings
2006-01-20 20:36:43,770 [2792] DEBUG NHibernate.Cfg.Binder [(null)] <(null)> - Second pass for collection: BugProject.ModelClasses.Line.Points
2006-01-20 20:36:43,780 [2792] INFO  NHibernate.Cfg.Binder [(null)] <(null)> - mapping collection: BugProject.ModelClasses.Line.Points -> T_Logical_Rail_Point
2006-01-20 20:36:43,780 [2792] DEBUG NHibernate.Cfg.Binder [(null)] <(null)> - Mapped collection key: Path_ID, one-to-many: RailPoint
2006-01-20 20:36:43,780 [2792] DEBUG NHibernate.Cfg.Binder [(null)] <(null)> - Second pass for collection: BugProject.ModelClasses.Model.Lines
2006-01-20 20:36:43,780 [2792] INFO  NHibernate.Cfg.Binder [(null)] <(null)> - mapping collection: BugProject.ModelClasses.Model.Lines -> T_Logical_Rail
2006-01-20 20:36:43,780 [2792] DEBUG NHibernate.Cfg.Binder [(null)] <(null)> - Mapped collection key: Model_Id, one-to-many: Line
2006-01-20 20:36:43,780 [2792] INFO  NHibernate.Cfg.Configuration [(null)] <(null)> - processing one-to-one association property references
2006-01-20 20:36:43,780 [2792] INFO  NHibernate.Cfg.Configuration [(null)] <(null)> - processing foreign key constraints
2006-01-20 20:36:43,780 [2792] DEBUG NHibernate.Cfg.Configuration [(null)] <(null)> - resolving reference to class: Model
2006-01-20 20:36:43,780 [2792] DEBUG NHibernate.Cfg.Configuration [(null)] <(null)> - resolving reference to class: Line
2006-01-20 20:36:43,800 [2792] INFO  NHibernate.Dialect.Dialect [(null)] <(null)> - Using dialect: NHibernate.Dialect.MsSql2000Dialect
2006-01-20 20:36:43,800 [2792] INFO  NHibernate.Cfg.SettingsFactory [(null)] <(null)> - use outer join fetching: True
2006-01-20 20:36:43,800 [2792] INFO  NHibernate.Connection.ConnectionProviderFactory [(null)] <(null)> - Intitializing connection provider: NHibernate.Connection.DriverConnectionProvider
2006-01-20 20:36:43,800 [2792] INFO  NHibernate.Connection.ConnectionProvider [(null)] <(null)> - Configuring ConnectionProvider
2006-01-20 20:36:43,800 [2792] INFO  NHibernate.Cfg.SettingsFactory [(null)] <(null)> - Optimize cache for minimal puts: False
2006-01-20 20:36:43,800 [2792] INFO  NHibernate.Cfg.SettingsFactory [(null)] <(null)> - Query language substitutions: {}
2006-01-20 20:36:43,800 [2792] INFO  NHibernate.Cfg.SettingsFactory [(null)] <(null)> - cache provider: NHibernate.Cache.HashtableCacheProvider
2006-01-20 20:36:43,810 [2792] INFO  NHibernate.Cfg.Configuration [(null)] <(null)> - instantiating and configuring caches
2006-01-20 20:36:43,820 [2792] INFO  NHibernate.Impl.SessionFactoryImpl [(null)] <(null)> - building session factory
2006-01-20 20:36:43,820 [2792] DEBUG NHibernate.Impl.SessionFactoryImpl [(null)] <(null)> - instantiating session factory with properties: {hibernate.connection.driver_class=NHibernate.Driver.SqlClientDriver, hibernate.dialect=NHibernate.Dialect.MsSql2000Dialect, hibernate.connection.provider=NHibernate.Connection.DriverConnectionProvider, hibernate.use_reflection_optimizer=True, hibernate.connection.connection_string=Trusted_Connection=yes; Data Source=localhost; Trusted_Connection=yes; database=BugProject}
2006-01-20 20:36:43,870 [2792] DEBUG NHibernate.Persister.GetSetHelperFactory [(null)] <(null)> - Init compiler for class BugProject.ModelClasses.Line
2006-01-20 20:36:43,870 [2792] DEBUG NHibernate.Persister.GetSetHelperFactory [(null)] <(null)> - Adding referenced assembly D:\_Works\_NET\CSharp\BugProject\bin\Debug\NHibernate.dll
2006-01-20 20:36:43,870 [2792] DEBUG NHibernate.Persister.GetSetHelperFactory [(null)] <(null)> - Adding referenced assembly D:\_Works\_NET\CSharp\BugProject\bin\Debug\BugProject.exe
2006-01-20 20:36:43,870 [2792] DEBUG NHibernate.Persister.GetSetHelperFactory [(null)] <(null)> - Adding referenced assembly D:\_Works\_NET\CSharp\BugProject\bin\Debug\Iesi.Collections.dll
2006-01-20 20:36:44,030 [2792] DEBUG NHibernate.Persister.GetSetHelperFactory [(null)] <(null)> - Compiled ok:
using System;
using NHibernate.Property;
namespace NHibernate.Persister {
public class GetSetHelper_BugProject_ModelClasses_Line : IGetSetHelper {
  ISetter[] setters;
  IGetter[] getters;
  public GetSetHelper_BugProject_ModelClasses_Line(ISetter[] setters, IGetter[] getters) {
    this.setters = setters;
    this.getters = getters;
  }
public void SetPropertyValues(object obj, object[] values) {
  BugProject.ModelClasses.Line t = (BugProject.ModelClasses.Line)obj;
  t.StartPoint = (BugProject.ModelClasses.Point)values[0];
  t.Points = (Iesi.Collections.ISet)values[1];
  t.EndPoint = (BugProject.ModelClasses.Point)values[2];
  t.Model = (BugProject.ModelClasses.Model)values[3];
}
public object[] GetPropertyValues(object obj) {
  BugProject.ModelClasses.Line t = (BugProject.ModelClasses.Line)obj;
  object[] ret = new object[4];
  ret[0] = t.StartPoint;
  ret[1] = t.Points;
  ret[2] = t.EndPoint;
  ret[3] = t.Model;
  return ret;
}
}
}

2006-01-20 20:36:44,040 [2792] DEBUG NHibernate.Persister.GetSetHelperFactory [(null)] <(null)> - Init compiler for class BugProject.ModelClasses.Model
2006-01-20 20:36:44,040 [2792] DEBUG NHibernate.Persister.GetSetHelperFactory [(null)] <(null)> - Adding referenced assembly D:\_Works\_NET\CSharp\BugProject\bin\Debug\NHibernate.dll
2006-01-20 20:36:44,040 [2792] DEBUG NHibernate.Persister.GetSetHelperFactory [(null)] <(null)> - Adding referenced assembly D:\_Works\_NET\CSharp\BugProject\bin\Debug\BugProject.exe
2006-01-20 20:36:44,040 [2792] DEBUG NHibernate.Persister.GetSetHelperFactory [(null)] <(null)> - Adding referenced assembly C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll
2006-01-20 20:36:44,040 [2792] DEBUG NHibernate.Persister.GetSetHelperFactory [(null)] <(null)> - Adding referenced assembly D:\_Works\_NET\CSharp\BugProject\bin\Debug\Iesi.Collections.dll
2006-01-20 20:36:44,190 [2792] DEBUG NHibernate.Persister.GetSetHelperFactory [(null)] <(null)> - Compiled ok:
using System;
using NHibernate.Property;
namespace NHibernate.Persister {
public class GetSetHelper_BugProject_ModelClasses_Model : IGetSetHelper {
  ISetter[] setters;
  IGetter[] getters;
  public GetSetHelper_BugProject_ModelClasses_Model(ISetter[] setters, IGetter[] getters) {
    this.setters = setters;
    this.getters = getters;
  }
public void SetPropertyValues(object obj, object[] values) {
  BugProject.ModelClasses.Model t = (BugProject.ModelClasses.Model)obj;
  t.Name = (System.String)values[0];
  t.Lines = (Iesi.Collections.ISet)values[1];
  t.Type = values[2] == null ? new System.Int32() : (System.Int32)values[2];
  t.Info = (System.String)values[3];
}
public object[] GetPropertyValues(object obj) {
  BugProject.ModelClasses.Model t = (BugProject.ModelClasses.Model)obj;
  object[] ret = new object[4];
  ret[0] = t.Name;
  ret[1] = t.Lines;
  ret[2] = t.Type;
  ret[3] = t.Info;
  return ret;
}
}
}

2006-01-20 20:36:44,190 [2792] DEBUG NHibernate.Persister.GetSetHelperFactory [(null)] <(null)> - Init compiler for class BugProject.ModelClasses.RailPoint
2006-01-20 20:36:44,190 [2792] DEBUG NHibernate.Persister.GetSetHelperFactory [(null)] <(null)> - Adding referenced assembly D:\_Works\_NET\CSharp\BugProject\bin\Debug\NHibernate.dll
2006-01-20 20:36:44,190 [2792] DEBUG NHibernate.Persister.GetSetHelperFactory [(null)] <(null)> - Adding referenced assembly D:\_Works\_NET\CSharp\BugProject\bin\Debug\BugProject.exe
2006-01-20 20:36:44,350 [2792] DEBUG NHibernate.Persister.GetSetHelperFactory [(null)] <(null)> - Compiled ok:
using System;
using NHibernate.Property;
namespace NHibernate.Persister {
public class GetSetHelper_BugProject_ModelClasses_RailPoint : IGetSetHelper {
  ISetter[] setters;
  IGetter[] getters;
  public GetSetHelper_BugProject_ModelClasses_RailPoint(ISetter[] setters, IGetter[] getters) {
    this.setters = setters;
    this.getters = getters;
  }
public void SetPropertyValues(object obj, object[] values) {
  BugProject.ModelClasses.RailPoint t = (BugProject.ModelClasses.RailPoint)obj;
  t.Line = (BugProject.ModelClasses.Line)values[0];
  t.Point = (BugProject.ModelClasses.Point)values[1];
}
public object[] GetPropertyValues(object obj) {
  BugProject.ModelClasses.RailPoint t = (BugProject.ModelClasses.RailPoint)obj;
  object[] ret = new object[2];
  ret[0] = t.Line;
  ret[1] = t.Point;
  return ret;
}
}
}

2006-01-20 20:36:44,491 [2792] DEBUG NHibernate.Impl.SessionFactoryObjectFactory [(null)] <(null)> - initializing class SessionFactoryObjectFactory
2006-01-20 20:36:44,491 [2792] DEBUG NHibernate.Impl.SessionFactoryObjectFactory [(null)] <(null)> - registered: a25442e14c1847769d5c21279350f740(unnamed)
2006-01-20 20:36:44,491 [2792] INFO  NHibernate.Impl.SessionFactoryObjectFactory [(null)] <(null)> - no name configured
2006-01-20 20:36:44,491 [2792] DEBUG NHibernate.Impl.SessionFactoryImpl [(null)] <(null)> - Instantiated session factory
2006-01-20 20:36:44,511 [2792] DEBUG NHibernate.Impl.SessionImpl [(null)] <(null)> - opened session
2006-01-20 20:36:45,532 [2792] DEBUG NHibernate.Transaction.AdoTransaction [(null)] <(null)> - begin
2006-01-20 20:36:45,532 [2792] DEBUG NHibernate.Connection.DriverConnectionProvider [(null)] <(null)> - Obtaining IDbConnection from Driver
2006-01-20 20:36:45,712 [2792] DEBUG NHibernate.Impl.SessionImpl [(null)] <(null)> - saving [BugProject.ModelClasses.Model#<null>]
2006-01-20 20:36:45,722 [2792] DEBUG NHibernate.Impl.SessionImpl [(null)] <(null)> - executing insertions
2006-01-20 20:36:45,732 [2792] DEBUG NHibernate.Engine.Cascades [(null)] <(null)> - processing cascades for: BugProject.ModelClasses.Model
2006-01-20 20:36:45,742 [2792] DEBUG NHibernate.Engine.Cascades [(null)] <(null)> - done processing cascades for: BugProject.ModelClasses.Model
2006-01-20 20:36:45,782 [2792] DEBUG NHibernate.Impl.WrapVisitor [(null)] <(null)> - Wrapped collection in role: BugProject.ModelClasses.Model.Lines
2006-01-20 20:36:45,792 [2792] DEBUG NHibernate.Persister.EntityPersister [(null)] <(null)> - Inserting entity: BugProject.ModelClasses.Model (native id)
2006-01-20 20:36:45,802 [2792] DEBUG NHibernate.Impl.BatcherImpl [(null)] <(null)> - Opened new IDbCommand, open IDbCommands :1
2006-01-20 20:36:45,802 [2792] DEBUG NHibernate.Impl.BatcherImpl [(null)] <(null)> - Building an IDbCommand object for the SqlString: INSERT INTO T_Model_Master (Model_Name, Model_Type, Model_Info) VALUES (:Model_Name, :Model_Type, :Model_Info); select SCOPE_IDENTITY()
2006-01-20 20:36:45,802 [2792] DEBUG NHibernate.Persister.EntityPersister [(null)] <(null)> - Dehydrating entity: [BugProject.ModelClasses.Model#<null>]
2006-01-20 20:36:45,802 [2792] DEBUG NHibernate.Type.StringType [(null)] <(null)> - binding 'Bug model' to parameter: 0
2006-01-20 20:36:45,802 [2792] DEBUG NHibernate.Type.Int32Type [(null)] <(null)> - binding '1' to parameter: 1
2006-01-20 20:36:45,812 [2792] DEBUG NHibernate.Type.StringType [(null)] <(null)> - binding 'Bug model' to parameter: 2
2006-01-20 20:36:45,812 [2792] DEBUG NHibernate.SQL [(null)] <(null)> - INSERT INTO T_Model_Master (Model_Name, Model_Type, Model_Info) VALUES (@p0, @p1, @p2); select SCOPE_IDENTITY()
2006-01-20 20:36:45,812 [2792] DEBUG NHibernate.Impl.BatcherImpl [(null)] <(null)> - Opened Reader, open Readers :1
2006-01-20 20:36:45,812 [2792] DEBUG NHibernate.Persister.AbstractEntityPersister [(null)] <(null)> - Natively generated identity: 3
2006-01-20 20:36:45,822 [2792] DEBUG NHibernate.Driver.NHybridDataReader [(null)] <(null)> - running NHybridDataReader.Dispose()
2006-01-20 20:36:45,822 [2792] DEBUG NHibernate.Impl.BatcherImpl [(null)] <(null)> - Closed Reader, open Readers :0
2006-01-20 20:36:45,822 [2792] DEBUG NHibernate.Impl.BatcherImpl [(null)] <(null)> - Closed IDbCommand, open IDbCommands :0
2006-01-20 20:36:45,822 [2792] DEBUG NHibernate.Engine.Cascades [(null)] <(null)> - processing cascades for: BugProject.ModelClasses.Model
2006-01-20 20:36:45,822 [2792] DEBUG NHibernate.Engine.Cascades [(null)] <(null)> - cascading to collection: BugProject.ModelClasses.Model.Lines
2006-01-20 20:36:45,832 [2792] DEBUG NHibernate.Engine.Cascades [(null)] <(null)> - cascading to SaveOrUpdate()
2006-01-20 20:36:45,832 [2792] DEBUG NHibernate.Engine.Cascades [(null)] <(null)> - unsaved-value: 0
2006-01-20 20:36:45,832 [2792] DEBUG NHibernate.Impl.SessionImpl [(null)] <(null)> - SaveOrUpdate() unsaved instance
2006-01-20 20:36:45,832 [2792] DEBUG NHibernate.Impl.SessionImpl [(null)] <(null)> - saving [BugProject.ModelClasses.Line#<null>]
2006-01-20 20:36:45,832 [2792] DEBUG NHibernate.Impl.SessionImpl [(null)] <(null)> - executing insertions
2006-01-20 20:36:45,832 [2792] DEBUG NHibernate.Engine.Cascades [(null)] <(null)> - processing cascades for: BugProject.ModelClasses.Line
2006-01-20 20:36:45,832 [2792] DEBUG NHibernate.Engine.Cascades [(null)] <(null)> - done processing cascades for: BugProject.ModelClasses.Line
2006-01-20 20:36:45,843 [2792] DEBUG NHibernate.Impl.WrapVisitor [(null)] <(null)> - Wrapped collection in role: BugProject.ModelClasses.Line.Points
2006-01-20 20:36:45,843 [2792] DEBUG NHibernate.Persister.EntityPersister [(null)] <(null)> - Inserting entity: BugProject.ModelClasses.Line (native id)
2006-01-20 20:36:45,843 [2792] DEBUG NHibernate.Impl.BatcherImpl [(null)] <(null)> - Opened new IDbCommand, open IDbCommands :1
2006-01-20 20:36:45,843 [2792] DEBUG NHibernate.Impl.BatcherImpl [(null)] <(null)> - Building an IDbCommand object for the SqlString: INSERT INTO T_Logical_Rail (X0_Coord, Y0_Coord, X1_Coord, Y1_Coord, Model_Id) VALUES (:X0_Coord, :Y0_Coord, :X1_Coord, :Y1_Coord, :Model_Id); select SCOPE_IDENTITY()
2006-01-20 20:36:45,843 [2792] DEBUG NHibernate.Persister.EntityPersister [(null)] <(null)> - Dehydrating entity: [BugProject.ModelClasses.Line#<null>]
2006-01-20 20:36:45,843 [2792] DEBUG NHibernate.Type.Int32Type [(null)] <(null)> - binding '1' to parameter: 0
2006-01-20 20:36:45,843 [2792] DEBUG NHibernate.Type.Int32Type [(null)] <(null)> - binding '10' to parameter: 1
2006-01-20 20:36:45,843 [2792] DEBUG NHibernate.Type.Int32Type [(null)] <(null)> - binding '1' to parameter: 2
2006-01-20 20:36:45,843 [2792] DEBUG NHibernate.Type.Int32Type [(null)] <(null)> - binding '20' to parameter: 3
2006-01-20 20:36:45,853 [2792] DEBUG NHibernate.Type.Int32Type [(null)] <(null)> - binding '3' to parameter: 4
2006-01-20 20:36:45,853 [2792] DEBUG NHibernate.SQL [(null)] <(null)> - INSERT INTO T_Logical_Rail (X0_Coord, Y0_Coord, X1_Coord, Y1_Coord, Model_Id) VALUES (@p0, @p1, @p2, @p3, @p4); select SCOPE_IDENTITY()
2006-01-20 20:36:45,853 [2792] DEBUG NHibernate.Impl.BatcherImpl [(null)] <(null)> - Opened Reader, open Readers :1
2006-01-20 20:36:45,853 [2792] DEBUG NHibernate.Persister.AbstractEntityPersister [(null)] <(null)> - Natively generated identity: 3
2006-01-20 20:36:45,853 [2792] DEBUG NHibernate.Driver.NHybridDataReader [(null)] <(null)> - running NHybridDataReader.Dispose()
2006-01-20 20:36:45,853 [2792] DEBUG NHibernate.Impl.BatcherImpl [(null)] <(null)> - Closed Reader, open Readers :0
2006-01-20 20:36:45,853 [2792] DEBUG NHibernate.Impl.BatcherImpl [(null)] <(null)> - Closed IDbCommand, open IDbCommands :0
2006-01-20 20:36:45,853 [2792] DEBUG NHibernate.Engine.Cascades [(null)] <(null)> - processing cascades for: BugProject.ModelClasses.Line
2006-01-20 20:36:45,853 [2792] DEBUG NHibernate.Engine.Cascades [(null)] <(null)> - cascading to collection: BugProject.ModelClasses.Line.Points
2006-01-20 20:36:45,853 [2792] DEBUG NHibernate.Engine.Cascades [(null)] <(null)> - cascading to SaveOrUpdate()
2006-01-20 20:36:45,853 [2792] DEBUG NHibernate.Engine.Cascades [(null)] <(null)> - unsaved-value: 0
2006-01-20 20:36:45,853 [2792] DEBUG NHibernate.Impl.SessionImpl [(null)] <(null)> - SaveOrUpdate() unsaved instance
2006-01-20 20:36:45,853 [2792] DEBUG NHibernate.Impl.SessionImpl [(null)] <(null)> - saving [BugProject.ModelClasses.RailPoint#<null>]
2006-01-20 20:36:45,853 [2792] DEBUG NHibernate.Impl.SessionImpl [(null)] <(null)> - executing insertions
2006-01-20 20:36:45,853 [2792] DEBUG NHibernate.Persister.EntityPersister [(null)] <(null)> - Inserting entity: BugProject.ModelClasses.RailPoint (native id)
2006-01-20 20:36:45,853 [2792] DEBUG NHibernate.Impl.BatcherImpl [(null)] <(null)> - Opened new IDbCommand, open IDbCommands :1
2006-01-20 20:36:45,853 [2792] DEBUG NHibernate.Impl.BatcherImpl [(null)] <(null)> - Building an IDbCommand object for the SqlString: INSERT INTO T_Logical_Rail_Point (Path_ID, X_Coord, Y_Coord) VALUES (:Path_ID, :X_Coord, :Y_Coord); select SCOPE_IDENTITY()
2006-01-20 20:36:45,853 [2792] DEBUG NHibernate.Persister.EntityPersister [(null)] <(null)> - Dehydrating entity: [BugProject.ModelClasses.RailPoint#<null>]
2006-01-20 20:36:45,853 [2792] DEBUG NHibernate.Type.Int32Type [(null)] <(null)> - binding '3' to parameter: 0
2006-01-20 20:36:45,853 [2792] DEBUG NHibernate.Type.Int32Type [(null)] <(null)> - binding '1' to parameter: 1
2006-01-20 20:36:45,853 [2792] DEBUG NHibernate.Type.Int32Type [(null)] <(null)> - binding '10' to parameter: 2
2006-01-20 20:36:45,853 [2792] DEBUG NHibernate.SQL [(null)] <(null)> - INSERT INTO T_Logical_Rail_Point (Path_ID, X_Coord, Y_Coord) VALUES (@p0, @p1, @p2); select SCOPE_IDENTITY()
2006-01-20 20:36:45,883 [2792] DEBUG NHibernate.Impl.BatcherImpl [(null)] <(null)> - Closed IDbCommand, open IDbCommands :0
2006-01-20 20:36:45,883 [2792] DEBUG NHibernate.Util.ADOExceptionReporter [(null)] <(null)> - could not insert: [BugProject.ModelClasses.RailPoint]
System.Data.SqlClient.SqlException: Cannot insert the value NULL into column 'Model_ID', table 'BugProject.dbo.T_Logical_Rail_Point'; column does not allow nulls. INSERT fails.
The statement has been terminated.
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
   at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
   at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
   at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
   at System.Data.SqlClient.SqlDataReader.get_MetaData()
   at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
   at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
   at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
   at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
   at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader()
   at NHibernate.Impl.BatcherImpl.ExecuteReader(IDbCommand cmd)
   at NHibernate.Persister.EntityPersister.Insert(Object[] fields, Boolean[] notNull, SqlString sql, Object obj, ISessionImplementor session)
2006-01-20 20:36:45,893 [2792] WARN  NHibernate.Util.ADOExceptionReporter [(null)] <(null)> - System.Data.SqlClient.SqlException: Cannot insert the value NULL into column 'Model_ID', table 'BugProject.dbo.T_Logical_Rail_Point'; column does not allow nulls. INSERT fails.
The statement has been terminated.
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
   at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
   at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
   at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
   at System.Data.SqlClient.SqlDataReader.get_MetaData()
   at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
   at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
   at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
   at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
   at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader()
   at NHibernate.Impl.BatcherImpl.ExecuteReader(IDbCommand cmd)
   at NHibernate.Persister.EntityPersister.Insert(Object[] fields, Boolean[] notNull, SqlString sql, Object obj, ISessionImplementor session)
2006-01-20 20:36:45,893 [2792] ERROR NHibernate.Util.ADOExceptionReporter [(null)] <(null)> - Cannot insert the value NULL into column 'Model_ID', table 'BugProject.dbo.T_Logical_Rail_Point'; column does not allow nulls. INSERT fails.
The statement has been terminated.
2006-01-20 20:36:45,893 [2792] ERROR NHibernate.ADOException [(null)] <(null)> - could not insert: [BugProject.ModelClasses.RailPoint]
System.Data.SqlClient.SqlException: Cannot insert the value NULL into column 'Model_ID', table 'BugProject.dbo.T_Logical_Rail_Point'; column does not allow nulls. INSERT fails.
The statement has been terminated.
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
   at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
   at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
   at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
   at System.Data.SqlClient.SqlDataReader.get_MetaData()
   at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
   at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
   at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
   at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
   at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader()
   at NHibernate.Impl.BatcherImpl.ExecuteReader(IDbCommand cmd)
   at NHibernate.Persister.EntityPersister.Insert(Object[] fields, Boolean[] notNull, SqlString sql, Object obj, ISessionImplementor session)


NH try to execute this statement

INSERT INTO T_Logical_Rail_Point (Path_ID, X_Coord, Y_Coord) VALUES (@p0, @p1, @p2); select SCOPE_IDENTITY()

Maybe I need to config for RailPoint class has some relation with Model class. But it's the first time I try to use NHibernate. :-(


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 20, 2006 11:31 am 
Newbie

Joined: Fri Jan 20, 2006 10:59 am
Posts: 2
As far as I can see you shouldn't have a Model_ID column in your T_Logical_Rail_Point table at all. What happens if you remove it?

Dave.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 20, 2006 10:06 pm 
Newbie

Joined: Mon Jan 09, 2006 4:57 am
Posts: 18
'Cause I use identifying relationship. Model-Line is one-to-many: so in Line, I must use Model_Id and Path_Id as primary keys. Line-RailPoint is one-to-many so in RailPoint I must use Model_Id, Path_Id and RailPoint_Id as primary keys.

If I change to non-identifying relationship, Model_Id in Line works as foreign key, Path_Id works as foreign key in RailPoint, no need Model_Id in RailiPoint any more. At that time I can insert to RailPoint but when I delete model, I can't not delete Line 'cause RailPoint still exists. Maybe when delete model, NHibernate can only check the relationship between Model and Line, it cannot check the relationship between Line and RailPoint.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 20, 2006 10:40 pm 
Newbie

Joined: Mon Jan 09, 2006 4:57 am
Posts: 18
If I change to non-identifying relation ship like this

Image

I will meet this exception

{"Cannot DELETE last T_Logical_Rail_Point because T_Logical_Rail exists."}

It can not delete only the last RailPoint.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 20, 2006 11:05 pm 
Newbie

Joined: Mon Jan 09, 2006 4:57 am
Posts: 18
I solved my problem.

+ First change from identifying relationship to non-identifying relationship
+ Then set RI actions looks like in the picture below for all non-identifying relationship (I'm using ERWin to support designing database)

Image


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 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.