Hi Marcal,
Thx for the help but i couldnt make it work.
Inserting new items succeeded but it is not updating the exisitng ones.
Can u b more specific?
I did not understand from the link what should i change.
I added a coulmn to SnapShotItem table and add a property for it(INT)
But how should i init it or assign that column?
The row i added to mapping file is:
<version name="Version"/>
and in the code:
public virtual int Version { get { return m_iVersion; } set { m_iVersion = value; } }
[2007-12-02 11:26:07](DEBUG): NHibernate.Impl.SessionImpl .ctor line(0):opened session
[2007-12-02 11:26:07](DEBUG): NHibernate.Transaction.AdoTransaction Begin line(0):begin
[2007-12-02 11:26:07](DEBUG): NHibernate.Engine.Cascades+IdentifierValue IsUnsaved line(0):unsaved-value: 0
[2007-12-02 11:26:07](DEBUG): NHibernate.Impl.SessionImpl SaveOrUpdate line(0):SaveOrUpdate() unsaved instance
[2007-12-02 11:26:07](DEBUG): NHibernate.Impl.SessionImpl DoSave line(0):saving [Retalix.Dax.Applications.PInv.SnapShotLocation#<null>]
[2007-12-02 11:26:07](DEBUG): NHibernate.Engine.Cascades Cascade line(0):processing cascades for: Retalix.Dax.Applications.PInv.SnapShotLocation
[2007-12-02 11:26:07](DEBUG): NHibernate.Engine.Cascades Cascade line(0):done processing cascades for: Retalix.Dax.Applications.PInv.SnapShotLocation
[2007-12-02 11:26:07](DEBUG): NHibernate.Impl.SessionImpl ExecuteInserts line(0):executing insertions
[2007-12-02 11:26:07](DEBUG): NHibernate.Impl.WrapVisitor ProcessArrayOrNewCollection line(0):Wrapped collection in role: Retalix.Dax.Applications.PInv.SnapShotLocation.Items
[2007-12-02 11:26:07](DEBUG): NHibernate.Persister.Entity.AbstractEntityPersister Insert line(0):Inserting entity: Retalix.Dax.Applications.PInv.SnapShotLocation (native id)
[2007-12-02 11:26:07](DEBUG): NHibernate.Impl.BatcherImpl LogOpenPreparedCommand line(0):Opened new IDbCommand, open IDbCommands: 1
[2007-12-02 11:26:07](DEBUG): NHibernate.Impl.BatcherImpl Generate line(0):Building an IDbCommand object for the SqlString: INSERT INTO PID_SnapshotLocation (LocationID, SnapShotDate) VALUES (?, ?); select SCOPE_IDENTITY()
[2007-12-02 11:26:07](DEBUG): NHibernate.Persister.Entity.AbstractEntityPersister Dehydrate line(0):Dehydrating entity: [Retalix.Dax.Applications.PInv.SnapShotLocation#<null>]
[2007-12-02 11:26:07](DEBUG): NHibernate.Type.NullableType NullSafeSet line(0):binding '1' to parameter: 0
[2007-12-02 11:26:07](DEBUG): NHibernate.Type.NullableType NullSafeSet line(0):binding '12/2/2007' to parameter: 1
[2007-12-02 11:26:07](DEBUG): NHibernate.Impl.BatcherImpl LogCommand line(0):INSERT INTO PID_SnapshotLocation (LocationID, SnapShotDate) VALUES (@p0, @p1); select SCOPE_IDENTITY(); @p0 = '1', @p1 = '12/2/2007 11:26:07 AM'
[2007-12-02 11:26:07](DEBUG): NHibernate.Impl.BatcherImpl LogOpenReader line(0):Opened IDataReader, open IDataReaders: 1
[2007-12-02 11:26:07](DEBUG): NHibernate.Type.NullableType NullSafeGet line(0):returning '30' as column:
[2007-12-02 11:26:07](DEBUG): NHibernate.Persister.Entity.AbstractEntityPersister GetGeneratedIdentity line(0):Natively generated identity: 30
[2007-12-02 11:26:07](DEBUG): NHibernate.Driver.NHybridDataReader Dispose line(0):running NHybridDataReader.Dispose()
[2007-12-02 11:26:07](DEBUG): NHibernate.Impl.BatcherImpl LogCloseReader line(0):Closed IDataReader, open IDataReaders :0
[2007-12-02 11:26:07](DEBUG): NHibernate.Impl.BatcherImpl LogClosePreparedCommand line(0):Closed IDbCommand, open IDbCommands: 0
[2007-12-02 11:26:07](DEBUG): NHibernate.Engine.Cascades Cascade line(0):processing cascades for: Retalix.Dax.Applications.PInv.SnapShotLocation
[2007-12-02 11:26:07](DEBUG): NHibernate.Engine.Cascades CascadeCollection line(0):cascading to collection: Retalix.Dax.Applications.PInv.SnapShotLocation.Items
[2007-12-02 11:26:07](DEBUG): NHibernate.Engine.Cascades+CascadingAction+ActionSaveUpdateClass Cascade line(0):cascading to SaveOrUpdate()
[2007-12-02 11:26:07](DEBUG): NHibernate.Engine.Cascades+VersionValue IsUnsaved line(0):unsaved-value: 0
[2007-12-02 11:26:07](DEBUG): NHibernate.Impl.SessionImpl SaveOrUpdate line(0):SaveOrUpdate() unsaved instance
[2007-12-02 11:26:07](DEBUG): NHibernate.Impl.SessionImpl SaveWithGeneratedIdentifier line(0):generated identifier: 2
[2007-12-02 11:26:07](DEBUG): NHibernate.Impl.SessionImpl DoSave line(0):saving [Retalix.Dax.Applications.PInv.SnapShotItem#2]
[2007-12-02 11:26:07](DEBUG): NHibernate.Engine.Cascades Cascade line(0):processing cascades for: Retalix.Dax.Applications.PInv.SnapShotItem
[2007-12-02 11:26:07](DEBUG): NHibernate.Engine.Cascades+CascadingAction+ActionSaveUpdateClass Cascade line(0):cascading to SaveOrUpdate()
[2007-12-02 11:26:07](DEBUG): NHibernate.Impl.SessionImpl SaveOrUpdate line(0):SaveOrUpdate() persistent instance
[2007-12-02 11:26:07](DEBUG): NHibernate.Engine.Cascades Cascade line(0):done processing cascades for: Retalix.Dax.Applications.PInv.SnapShotItem
[2007-12-02 11:26:07](DEBUG): NHibernate.Engine.Cascades+VersionValue IsUnsaved line(0):unsaved-value: 0
[2007-12-02 11:26:07](DEBUG): NHibernate.Engine.Versioning Seed line(0):Seeding: 1
[2007-12-02 11:26:07](DEBUG): NHibernate.Engine.Cascades Cascade line(0):processing cascades for: Retalix.Dax.Applications.PInv.SnapShotItem
[2007-12-02 11:26:07](DEBUG): NHibernate.Engine.Cascades Cascade line(0):done processing cascades for: Retalix.Dax.Applications.PInv.SnapShotItem
[2007-12-02 11:26:07](DEBUG): NHibernate.Engine.Cascades Cascade line(0):done processing cascades for: Retalix.Dax.Applications.PInv.SnapShotLocation
[2007-12-02 11:26:07](DEBUG): NHibernate.Transaction.AdoTransaction Commit line(0):commit
[2007-12-02 11:26:07](DEBUG): NHibernate.Impl.SessionImpl FlushEverything line(0):flushing session
[2007-12-02 11:26:07](DEBUG): NHibernate.Engine.Cascades Cascade line(0):processing cascades for: Retalix.Dax.Applications.PInv.SnapShotLocation
[2007-12-02 11:26:07](DEBUG): NHibernate.Engine.Cascades CascadeCollection line(0):cascading to collection: Retalix.Dax.Applications.PInv.SnapShotLocation.Items
[2007-12-02 11:26:07](DEBUG): NHibernate.Engine.Cascades+CascadingAction+ActionSaveUpdateClass Cascade line(0):cascading to SaveOrUpdate()
[2007-12-02 11:26:07](DEBUG): NHibernate.Impl.SessionImpl SaveOrUpdate line(0):SaveOrUpdate() persistent instance
[2007-12-02 11:26:07](DEBUG): NHibernate.Engine.Cascades Cascade line(0):done processing cascades for: Retalix.Dax.Applications.PInv.SnapShotLocation
[2007-12-02 11:26:07](DEBUG): NHibernate.Engine.Cascades Cascade line(0):processing cascades for: Retalix.Dax.Applications.PInv.SnapShotItem
[2007-12-02 11:26:07](DEBUG): NHibernate.Engine.Cascades+CascadingAction+ActionSaveUpdateClass Cascade line(0):cascading to SaveOrUpdate()
[2007-12-02 11:26:07](DEBUG): NHibernate.Impl.SessionImpl SaveOrUpdate line(0):SaveOrUpdate() persistent instance
[2007-12-02 11:26:07](DEBUG): NHibernate.Engine.Cascades Cascade line(0):done processing cascades for: Retalix.Dax.Applications.PInv.SnapShotItem
[2007-12-02 11:26:07](DEBUG): NHibernate.Impl.SessionImpl FlushEntities line(0):Flushing entities and processing referenced collections
[2007-12-02 11:26:08](DEBUG): NHibernate.Impl.FlushVisitor ProcessCollection line(0):Processing collection for role Retalix.Dax.Applications.PInv.SnapShotLocation.Items
[2007-12-02 11:26:08](DEBUG): NHibernate.Impl.SessionImpl UpdateReachableCollection line(0):Collection found: [Retalix.Dax.Applications.PInv.SnapShotLocation.Items#30], was: [<unreferenced>]
[2007-12-02 11:26:08](DEBUG): NHibernate.Impl.SessionImpl FlushCollections line(0):Processing unreferenced collections
[2007-12-02 11:26:08](DEBUG): NHibernate.Impl.SessionImpl FlushCollections line(0):scheduling collection removes/(re)creates/updates
[2007-12-02 11:26:08](DEBUG): NHibernate.Impl.SessionImpl FlushEverything line(0):Flushed: 1 insertions, 0 updates, 0 deletions to 2 objects
[2007-12-02 11:26:08](DEBUG): NHibernate.Impl.SessionImpl FlushEverything line(0):Flushed: 1 (re)creations, 0 updates, 0 removals to 1 collections
[2007-12-02 11:26:08](DEBUG): NHibernate.Impl.Printer ToString line(0):listing entities:
[2007-12-02 11:26:08](DEBUG): NHibernate.Impl.Printer ToString line(0):Retalix.Dax.Applications.PInv.SnapShotItem{Version=1, ItemQuantity=1, ItemID=2, ItemCost=1, CountDate=12/2/2007, CountAmount=1, SnapShotID=SnapShotLocation#30}
[2007-12-02 11:26:08](DEBUG): NHibernate.Impl.Printer ToString line(0):Retalix.Dax.Applications.PInv.SnapShotLocation{LocationID=1, Items=[SnapShotItem#2], SnapShotDate=12/2/2007, SnapShotID=30}
[2007-12-02 11:26:08](DEBUG): NHibernate.Impl.SessionImpl Execute line(0):executing flush
[2007-12-02 11:26:08](DEBUG): NHibernate.Impl.ConnectionManager FlushBeginning line(0):registering flush begin
[2007-12-02 11:26:08](DEBUG): NHibernate.Persister.Entity.AbstractEntityPersister Insert line(0):Inserting entity: [Retalix.Dax.Applications.PInv.SnapShotItem#2]
[2007-12-02 11:26:08](DEBUG): NHibernate.Persister.Entity.AbstractEntityPersister Insert line(0):Version: 1
[2007-12-02 11:26:08](DEBUG): NHibernate.Impl.BatcherImpl LogOpenPreparedCommand line(0):Opened new IDbCommand, open IDbCommands: 1
[2007-12-02 11:26:08](DEBUG): NHibernate.Impl.BatcherImpl Generate line(0):Building an IDbCommand object for the SqlString: INSERT INTO PID_SnapshotItems (Version, SnapShotID, Quantity, InvCountDate, InvCountQuantity, ItemCost, ItemID) VALUES (?, ?, ?, ?, ?, ?, ?)
[2007-12-02 11:26:08](DEBUG): NHibernate.Persister.Entity.AbstractEntityPersister Dehydrate line(0):Dehydrating entity: [Retalix.Dax.Applications.PInv.SnapShotItem#2]
[2007-12-02 11:26:08](DEBUG): NHibernate.Type.NullableType NullSafeSet line(0):binding '1' to parameter: 0
[2007-12-02 11:26:08](DEBUG): NHibernate.Type.NullableType NullSafeSet line(0):binding '30' to parameter: 1
[2007-12-02 11:26:08](DEBUG): NHibernate.Type.NullableType NullSafeSet line(0):binding '1' to parameter: 2
[2007-12-02 11:26:08](DEBUG): NHibernate.Type.NullableType NullSafeSet line(0):binding '12/2/2007' to parameter: 3
[2007-12-02 11:26:08](DEBUG): NHibernate.Type.NullableType NullSafeSet line(0):binding '1' to parameter: 4
[2007-12-02 11:26:08](DEBUG): NHibernate.Type.NullableType NullSafeSet line(0):binding '1' to parameter: 5
[2007-12-02 11:26:08](DEBUG): NHibernate.Type.NullableType NullSafeSet line(0):binding '2' to parameter: 6
[2007-12-02 11:26:08](DEBUG): NHibernate.Impl.BatcherImpl LogCommand line(0):INSERT INTO PID_SnapshotItems (Version, SnapShotID, Quantity, InvCountDate, InvCountQuantity, ItemCost, ItemID) VALUES (@p0, @p1, @p2, @p3, @p4, @p5, @p6); @p0 = '1', @p1 = '30', @p2 = '1', @p3 = '12/2/2007 11:26:07 AM', @p4 = '1', @p5 = '1', @p6 = '2'
[2007-12-02 11:26:08](DEBUG): NHibernate.Impl.BatcherImpl LogClosePreparedCommand line(0):Closed IDbCommand, open IDbCommands: 0
[2007-12-02 11:26:08](DEBUG): NHibernate.Util.ADOExceptionReporter LogExceptions line(0):could not insert: [Retalix.Dax.Applications.PInv.SnapShotItem#2] [INSERT INTO PID_SnapshotItems (Version, SnapShotID, Quantity, InvCountDate, InvCountQuantity, ItemCost, ItemID) VALUES (?, ?, ?, ?, ?, ?, ?)]
System.Data.SqlClient.SqlException: Violation of PRIMARY KEY constraint 'PK_PID_SnapshotItems'. Cannot insert duplicate key in object 'dbo.PID_SnapshotItems'.
The statement has been terminated.
Thx,
Tomer
|