NHibernate HasMany cause KeyNotFoundException on Delete

152 views
Skip to first unread message

Frank

unread,
Oct 22, 2010, 4:58:53 AM10/22/10
to Fluent NHibernate
hi. i use oracle and nhibernate3 alpha. i have a parent child
relation. the child table has a composite id. Select, insert and
update records works, but deleting a parent with childs or just delete
a child throws a KeyNotFoundException. it seems i miss something in my
mapping?

below my entity classes and mappings

public class DruckUndVersand
{
public DruckUndVersand()
{
this.RefFilters = new List<RefDruckUndVersandFilter>();
}

public virtual long Id { get; set; }
public virtual string Programm { get; set; }
public virtual string Variante { get; set; }
public virtual string Beschreibung { get; set; }
public virtual bool IsActive { get; set; }
public virtual IList<RefDruckUndVersandFilter> RefFilters { get;
set; }
}

public class RefDruckUndVersandFilter
{
public virtual DruckUndVersand DruckUndVersand { get; set; }
public virtual long Rank { get; set; }
public virtual string Filter { get; set; }

#region override Equals(), GetHashCode()
//
#endregion
}
my fluent mappings look like this:

public class DruckUndVersandMapper : ClassMap<DruckUndVersand>
{
public DruckUndVersandMapper()
{
Table("Tab_DruckUndVersand");
Id(x => x.Id,
"ID").GeneratedBy.Sequence("SEQ_DruckUndVersand");

Map(x => x.Programm).Not.Nullable().Length(255);
Map(x => x.Variante).Length(255);
Map(x => x.Beschreibung).Length(255);
Map(x =>
x.IsActive).Column("ISACTIVE").CustomType<YesNoType>().Length(1);

HasMany(x => x.RefFilters)
.KeyColumn("IDDruckUndVersand")
.NotFound.Ignore()
.Inverse()
.Cascade.All()
;
}
}

public class RefDruckUndVersandFilterMapper :
ClassMap<RefDruckUndVersandFilter>
{
public RefDruckUndVersandFilterMapper()
{
Table("REFDruckUndVersandFILTER");
Not.LazyLoad();
Map(x => x.Filter);
CompositeId()
.KeyReference(x => x.DruckUndVersand, "IDDruckUndVersand")
.KeyProperty(x => x.Rank, "FILTERRANK");

}
}

James Gregory

unread,
Oct 24, 2010, 6:09:48 AM10/24/10
to fluent-n...@googlegroups.com
How are you deleting the entities? Are you removing them from the collection on DruckUndVersand or deleting them directly using Session.Delete?

If it's from the collection, it could be because your HasMany only specifies one column for the key while your mapping specifies two.


--
You received this message because you are subscribed to the Google Groups "Fluent NHibernate" group.
To post to this group, send email to fluent-n...@googlegroups.com.
To unsubscribe from this group, send email to fluent-nhibern...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/fluent-nhibernate?hl=en.


Frank

unread,
Oct 24, 2010, 8:59:01 AM10/24/10
to Fluent NHibernate
hi james, i have both situations.

1st: if i have a parent(DruckUndVersand) with
childs(RefDruckUndVersandFilter) and i call ISession.Delete(parent) i
get KeyNotFoundException.
2nd: if i have a parent(DruckUndVersand) with
childs(RefDruckUndVersandFilter) and i remove some child from the
parent collection and call ISession.SaveOrUpdate(parent) i get
KeyNotFoundException too.

somethin strange is that the generated sql would work... but commit
transaction give me the error.

how should my HasMany look like? i'm really new to nhibernate at all

below some additional information

StackTrace

bei System.Collections.Generic.Dictionary`2.get_Item(TKey key)
bei
NHibernate.Engine.StatefulPersistenceContext.RemoveEntity(EntityKey
key) in d:\CSharp\NH\nhibernate\src\NHibernate\Engine
\StatefulPersistenceContext.cs:Zeile 434.
bei NHibernate.Action.EntityDeleteAction.Execute() in d:\CSharp\NH
\nhibernate\src\NHibernate\Action\EntityDeleteAction.cs:Zeile 86.
bei NHibernate.Engine.ActionQueue.Execute(IExecutable executable) in d:
\CSharp\NH\nhibernate\src\NHibernate\Engine\ActionQueue.cs:Zeile 130.
bei NHibernate.Engine.ActionQueue.ExecuteActions(IList list) in d:
\CSharp\NH\nhibernate\src\NHibernate\Engine\ActionQueue.cs:Zeile 113.
bei NHibernate.Engine.ActionQueue.ExecuteActions() in d:\CSharp\NH
\nhibernate\src\NHibernate\Engine\ActionQueue.cs:Zeile 151.
bei
NHibernate.Event.Default.AbstractFlushingEventListener.PerformExecutions(IEventSource
session) in d:\CSharp\NH\nhibernate\src\NHibernate\Event\Default
\AbstractFlushingEventListener.cs:Zeile 241.
bei
NHibernate.Event.Default.DefaultFlushEventListener.OnFlush(FlushEvent
event) in d:\CSharp\NH\nhibernate\src\NHibernate\Event\Default
\DefaultFlushEventListener.cs:Zeile 19.
bei NHibernate.Impl.SessionImpl.Flush() in d:\CSharp\NH\nhibernate\src
\NHibernate\Impl\SessionImpl.cs:Zeile 1524.
bei NHibernate.Transaction.AdoTransaction.Commit() in d:\CSharp\NH
\nhibernate\src\NHibernate\Transaction\AdoTransaction.cs:Zeile 187.
bei
LFF.Kabu.Win.Tabellenverwaltung.DataAccess.NHibernate.UnitOfWork.CommitTransaction()
in C:\Demos\Tabellenverwaltung\DataAccess.NHibernate
\UnitOfWork.cs:Zeile 77.
bei
LFF.Kabu.Win.TabModul.DruckUndVersand.ViewModel.DruckUndVersandVM.SaveData()


nhibernate log

15:15:09.249 [17] DEBUG NHibernate.Transaction.AdoTransaction - Begin
(ReadCommitted)
15:15:09.249 [17] DEBUG NHibernate.Connection.DriverConnectionProvider
- Obtaining IDbConnection from Driver
15:15:09.249 [17] DEBUG
NHibernate.Event.Default.DefaultDeleteEventListener - deleting a
persistent instance
15:15:09.249 [17] DEBUG
NHibernate.Event.Default.DefaultDeleteEventListener - deleting
[LFF.Kabu.Win.Tabellenverwaltung.Entities.DruckUndVersand#9]
15:15:09.249 [17] DEBUG NHibernate.Impl.SessionImpl - setting cache
mode to: Get
15:15:09.249 [17] INFO NHibernate.Engine.Cascade - processing cascade
NHibernate.Engine.CascadingAction+DeleteCascadingAction for:
LFF.Kabu.Win.Tabellenverwaltung.Entities.DruckUndVersand
15:15:09.249 [17] INFO NHibernate.Engine.Cascade - cascade
NHibernate.Engine.CascadingAction+DeleteCascadingAction for
collection:
LFF.Kabu.Win.Tabellenverwaltung.Entities.DruckUndVersand.RefFilters
15:15:09.264 [17] DEBUG NHibernate.Engine.CascadingAction - cascading
to delete:
LFF.Kabu.Win.Tabellenverwaltung.Entities.RefDruckUndVersandFilter
15:15:09.264 [17] DEBUG
NHibernate.Event.Default.DefaultDeleteEventListener - deleting a
persistent instance
15:15:09.264 [17] DEBUG
NHibernate.Event.Default.DefaultDeleteEventListener - deleting
[LFF.Kabu.Win.Tabellenverwaltung.Entities.RefDruckUndVersandFilter#LFF.Kabu.Win.Tabellenverwaltung.Entities.RefDruckUndVersandFilter]
15:15:09.264 [17] DEBUG NHibernate.Impl.SessionImpl - setting cache
mode to: Get
15:15:09.264 [17] DEBUG NHibernate.Impl.SessionImpl - setting cache
mode to: Get
15:15:09.264 [17] DEBUG NHibernate.Impl.SessionImpl - setting cache
mode to: Get
15:15:09.264 [17] DEBUG NHibernate.Impl.SessionImpl - setting cache
mode to: Get
15:15:09.264 [17] INFO NHibernate.Engine.Cascade - done cascade
NHibernate.Engine.CascadingAction+DeleteCascadingAction for
collection:
LFF.Kabu.Win.Tabellenverwaltung.Entities.DruckUndVersand.RefFilters
15:15:09.264 [17] INFO NHibernate.Engine.Cascade - cascade
NHibernate.Engine.CascadingAction+DeleteCascadingAction for
collection:
LFF.Kabu.Win.Tabellenverwaltung.Entities.DruckUndVersand.RefDruckUndVersandAusgaben
15:15:09.264 [17] DEBUG
NHibernate.Event.Default.DefaultInitializeCollectionEventListener -
initializing collection
[LFF.Kabu.Win.Tabellenverwaltung.Entities.DruckUndVersand.RefDruckUndVersandAusgaben#9]
15:15:09.264 [17] DEBUG
NHibernate.Event.Default.DefaultInitializeCollectionEventListener -
checking second-level cache
15:15:09.264 [17] DEBUG
NHibernate.Event.Default.DefaultInitializeCollectionEventListener -
collection not cached
15:15:09.264 [17] DEBUG NHibernate.Loader.Loader - loading collection:
[LFF.Kabu.Win.Tabellenverwaltung.Entities.DruckUndVersand.RefDruckUndVersandAusgaben#9]
15:15:09.264 [17] DEBUG NHibernate.AdoNet.AbstractBatcher - Opened new
IDbCommand, open IDbCommands: 1
15:15:09.264 [17] DEBUG NHibernate.AdoNet.AbstractBatcher - Building
an IDbCommand object for the SqlString: SELECT
refdruckun0_.IDDruckUndVersand as IDDruckU1_1_, refdruckun0_.IDAUSGABE
as IDAUSGABE1_, refdruckun0_.IDDruckUndVersand as IDDruckU1_3_0_,
refdruckun0_.IDAUSGABE as IDAUSGABE3_0_,
refdruckun0_.OBAUTOMATISCHDRUCKEN as OBAUTOMA3_3_0_,
refdruckun0_.Druckerpfad as Druckerp4_3_0_, refdruckun0_.Beschreibung
as Beschrei5_3_0_ FROM REFDruckUndVersandAUSGABE refdruckun0_ WHERE
refdruckun0_.IDDruckUndVersand=?
15:15:09.264 [17] DEBUG NHibernate.Engine.QueryParameters -
BindParameters(Positional0:NHibernate.Type.Int64Type) 9 -> [0]
15:15:09.264 [17] DEBUG NHibernate.Type.Int64Type - binding '9' to
parameter: 0
15:15:09.264 [17] INFO NHibernate.Loader.Loader - SELECT
refdruckun0_.IDDruckUndVersand as IDDruckU1_1_, refdruckun0_.IDAUSGABE
as IDAUSGABE1_, refdruckun0_.IDDruckUndVersand as IDDruckU1_3_0_,
refdruckun0_.IDAUSGABE as IDAUSGABE3_0_,
refdruckun0_.OBAUTOMATISCHDRUCKEN as OBAUTOMA3_3_0_,
refdruckun0_.Druckerpfad as Druckerp4_3_0_, refdruckun0_.Beschreibung
as Beschrei5_3_0_ FROM REFDruckUndVersandAUSGABE refdruckun0_ WHERE
refdruckun0_.IDDruckUndVersand=:p0
15:15:09.264 [17] DEBUG NHibernate.SQL - SELECT
refdruckun0_.IDDruckUndVersand as IDDruckU1_1_, refdruckun0_.IDAUSGABE
as IDAUSGABE1_, refdruckun0_.IDDruckUndVersand as IDDruckU1_3_0_,
refdruckun0_.IDAUSGABE as IDAUSGABE3_0_,
refdruckun0_.OBAUTOMATISCHDRUCKEN as OBAUTOMA3_3_0_,
refdruckun0_.Druckerpfad as Druckerp4_3_0_, refdruckun0_.Beschreibung
as Beschrei5_3_0_ FROM REFDruckUndVersandAUSGABE refdruckun0_ WHERE
refdruckun0_.IDDruckUndVersand=:p0;:p0 = 9 [Type: Int64 (0)]
15:15:09.264 [17] DEBUG NHibernate.Transaction.AdoTransaction - Enlist
Command
15:15:09.264 [17] DEBUG NHibernate.AdoNet.AbstractBatcher -
ExecuteReader took 1 ms
15:15:09.264 [17] DEBUG NHibernate.AdoNet.AbstractBatcher - Opened
IDataReader, open IDataReaders: 1
15:15:09.264 [17] DEBUG NHibernate.Loader.Loader - result set contains
(possibly empty) collection:
[LFF.Kabu.Win.Tabellenverwaltung.Entities.DruckUndVersand.RefDruckUndVersandAusgaben#9]
15:15:09.264 [17] DEBUG NHibernate.Engine.Loading.LoadContexts -
constructing collection load context for result set
[System.Data.OracleClient.OracleDataReader]
15:15:09.264 [17] DEBUG
NHibernate.Engine.Loading.CollectionLoadContext - starting attempt to
find loading collection
[[LFF.Kabu.Win.Tabellenverwaltung.Entities.DruckUndVersand.RefDruckUndVersandAusgaben#9]]
15:15:09.264 [17] DEBUG NHibernate.Engine.Loading.LoadContexts -
attempting to locate loading collection entry
[CollectionKey[LFF.Kabu.Win.Tabellenverwaltung.Entities.DruckUndVersand.RefDruckUndVersandAusgaben#9]]
in any result-set context
15:15:09.264 [17] DEBUG NHibernate.Engine.Loading.LoadContexts -
collection
[CollectionKey[LFF.Kabu.Win.Tabellenverwaltung.Entities.DruckUndVersand.RefDruckUndVersandAusgaben#9]]
located in load context
15:15:09.264 [17] DEBUG
NHibernate.Engine.Loading.CollectionLoadContext - collection not yet
initialized; initializing
15:15:09.264 [17] DEBUG NHibernate.Loader.Loader - processing result
set
15:15:09.264 [17] DEBUG NHibernate.Loader.Loader - done processing
result set (0 rows)
15:15:09.264 [17] DEBUG NHibernate.AdoNet.AbstractBatcher - Closed
IDataReader, open IDataReaders :0
15:15:09.264 [17] DEBUG NHibernate.AdoNet.AbstractBatcher - DataReader
was closed after 2 ms
15:15:09.264 [17] DEBUG NHibernate.AdoNet.AbstractBatcher - Closed
IDbCommand, open IDbCommands: 0
15:15:09.264 [17] DEBUG NHibernate.Loader.Loader - total objects
hydrated: 0
15:15:09.264 [17] DEBUG NHibernate.Engine.Loading.LoadContexts -
attempting to locate loading collection entry
[CollectionKey[LFF.Kabu.Win.Tabellenverwaltung.Entities.DruckUndVersand.RefDruckUndVersandAusgaben#9]]
in any result-set context
15:15:09.264 [17] DEBUG NHibernate.Engine.Loading.LoadContexts -
collection
[CollectionKey[LFF.Kabu.Win.Tabellenverwaltung.Entities.DruckUndVersand.RefDruckUndVersandAusgaben#9]]
not located in load context
15:15:09.264 [17] DEBUG
NHibernate.Engine.Loading.CollectionLoadContext - removing collection
load entry
[NHibernate.Engine.Loading.LoadingCollectionEntry<rs=System.Data.OracleClient.OracleDataReader,
coll=[LFF.Kabu.Win.Tabellenverwaltung.Entities.DruckUndVersand.RefDruckUndVersandAusgaben#9]>@69a2a7]
15:15:09.264 [17] DEBUG
NHibernate.Engine.Loading.CollectionLoadContext - 1 collections were
found in result set for role:
LFF.Kabu.Win.Tabellenverwaltung.Entities.DruckUndVersand.RefDruckUndVersandAusgaben
15:15:09.264 [17] DEBUG
NHibernate.Engine.Loading.CollectionLoadContext - ending loading
collection
[NHibernate.Engine.Loading.LoadingCollectionEntry<rs=System.Data.OracleClient.OracleDataReader,
coll=[LFF.Kabu.Win.Tabellenverwaltung.Entities.DruckUndVersand.RefDruckUndVersandAusgaben#9]>@69a2a7]
15:15:09.264 [17] DEBUG
NHibernate.Engine.Loading.CollectionLoadContext - collection fully
initialized:
[LFF.Kabu.Win.Tabellenverwaltung.Entities.DruckUndVersand.RefDruckUndVersandAusgaben#9]
15:15:09.264 [17] DEBUG
NHibernate.Engine.Loading.CollectionLoadContext - 1 collections
initialized for role:
LFF.Kabu.Win.Tabellenverwaltung.Entities.DruckUndVersand.RefDruckUndVersandAusgaben
15:15:09.264 [17] DEBUG NHibernate.Engine.StatefulPersistenceContext -
initializing non-lazy collections
15:15:09.264 [17] DEBUG NHibernate.Loader.Loader - done loading
collection
15:15:09.264 [17] DEBUG
NHibernate.Event.Default.DefaultInitializeCollectionEventListener -
collection initialized
15:15:09.264 [17] INFO NHibernate.Engine.Cascade - done cascade
NHibernate.Engine.CascadingAction+DeleteCascadingAction for
collection:
LFF.Kabu.Win.Tabellenverwaltung.Entities.DruckUndVersand.RefDruckUndVersandAusgaben
15:15:09.264 [17] INFO NHibernate.Engine.Cascade - done processing
cascade NHibernate.Engine.CascadingAction+DeleteCascadingAction for:
LFF.Kabu.Win.Tabellenverwaltung.Entities.DruckUndVersand
15:15:09.264 [17] DEBUG NHibernate.Impl.SessionImpl - setting cache
mode to: Normal
15:15:09.264 [17] DEBUG NHibernate.Impl.SessionImpl - setting cache
mode to: Get
15:15:09.264 [17] INFO NHibernate.Engine.Cascade - processing cascade
NHibernate.Engine.CascadingAction+DeleteCascadingAction for:
LFF.Kabu.Win.Tabellenverwaltung.Entities.DruckUndVersand
15:15:09.264 [17] INFO NHibernate.Engine.Cascade - done processing
cascade NHibernate.Engine.CascadingAction+DeleteCascadingAction for:
LFF.Kabu.Win.Tabellenverwaltung.Entities.DruckUndVersand
15:15:09.264 [17] DEBUG NHibernate.Impl.SessionImpl - setting cache
mode to: Normal
15:15:09.264 [17] DEBUG NHibernate.Transaction.AdoTransaction - Start
Commit
15:15:09.264 [17] DEBUG
NHibernate.Event.Default.AbstractFlushingEventListener - flushing
session
15:15:09.264 [17] DEBUG
NHibernate.Event.Default.AbstractFlushingEventListener - processing
flush-time cascades
15:15:09.264 [17] INFO NHibernate.Engine.Cascade - processing cascade
NHibernate.Engine.CascadingAction+SaveUpdateCascadingAction for:
LFF.Kabu.Win.Tabellenverwaltung.Entities.DruckUndVersand
15:15:09.264 [17] INFO NHibernate.Engine.Cascade - cascade
NHibernate.Engine.CascadingAction+SaveUpdateCascadingAction for
collection:
LFF.Kabu.Win.Tabellenverwaltung.Entities.DruckUndVersand.RefFilters
15:15:09.264 [17] INFO NHibernate.Engine.Cascade - done cascade
NHibernate.Engine.CascadingAction+SaveUpdateCascadingAction for
collection:
LFF.Kabu.Win.Tabellenverwaltung.Entities.DruckUndVersand.RefFilters
15:15:09.264 [17] INFO NHibernate.Engine.Cascade - cascade
NHibernate.Engine.CascadingAction+SaveUpdateCascadingAction for
collection:
LFF.Kabu.Win.Tabellenverwaltung.Entities.DruckUndVersand.RefDruckUndVersandAusgaben
15:15:09.264 [17] INFO NHibernate.Engine.Cascade - done cascade
NHibernate.Engine.CascadingAction+SaveUpdateCascadingAction for
collection:
LFF.Kabu.Win.Tabellenverwaltung.Entities.DruckUndVersand.RefDruckUndVersandAusgaben
15:15:09.264 [17] INFO NHibernate.Engine.Cascade - done processing
cascade NHibernate.Engine.CascadingAction+SaveUpdateCascadingAction
for: LFF.Kabu.Win.Tabellenverwaltung.Entities.DruckUndVersand
15:15:09.264 [17] INFO NHibernate.Engine.Cascade - processing cascade
NHibernate.Engine.CascadingAction+SaveUpdateCascadingAction for:
LFF.Kabu.Win.Tabellenverwaltung.Entities.DruckUndVersand
15:15:09.264 [17] INFO NHibernate.Engine.Cascade - cascade
NHibernate.Engine.CascadingAction+SaveUpdateCascadingAction for
collection:
LFF.Kabu.Win.Tabellenverwaltung.Entities.DruckUndVersand.RefFilters
15:15:09.264 [17] DEBUG NHibernate.Engine.CascadingAction - cascading
to saveOrUpdate:
LFF.Kabu.Win.Tabellenverwaltung.Entities.RefDruckUndVersandFilter
15:15:09.296 [17] DEBUG
NHibernate.Event.Default.AbstractSaveEventListener - persistent
instance of:
LFF.Kabu.Win.Tabellenverwaltung.Entities.RefDruckUndVersandFilter
15:15:09.296 [17] DEBUG
NHibernate.Event.Default.DefaultSaveOrUpdateEventListener - ignoring
persistent instance
15:15:09.296 [17] DEBUG
NHibernate.Event.Default.DefaultSaveOrUpdateEventListener - object
already associated with session:
[LFF.Kabu.Win.Tabellenverwaltung.Entities.RefDruckUndVersandFilter#LFF.Kabu.Win.Tabellenverwaltung.Entities.RefDruckUndVersandFilter]
15:15:09.296 [17] INFO NHibernate.Engine.Cascade - done cascade
NHibernate.Engine.CascadingAction+SaveUpdateCascadingAction for
collection:
LFF.Kabu.Win.Tabellenverwaltung.Entities.DruckUndVersand.RefFilters
15:15:09.296 [17] INFO NHibernate.Engine.Cascade - cascade
NHibernate.Engine.CascadingAction+SaveUpdateCascadingAction for
collection:
LFF.Kabu.Win.Tabellenverwaltung.Entities.DruckUndVersand.RefDruckUndVersandAusgaben
15:15:09.296 [17] INFO NHibernate.Engine.Cascade - done cascade
NHibernate.Engine.CascadingAction+SaveUpdateCascadingAction for
collection:
LFF.Kabu.Win.Tabellenverwaltung.Entities.DruckUndVersand.RefDruckUndVersandAusgaben
15:15:09.296 [17] INFO NHibernate.Engine.Cascade - done processing
cascade NHibernate.Engine.CascadingAction+SaveUpdateCascadingAction
for: LFF.Kabu.Win.Tabellenverwaltung.Entities.DruckUndVersand
15:15:09.296 [17] INFO NHibernate.Engine.Cascade - processing cascade
NHibernate.Engine.CascadingAction+SaveUpdateCascadingAction for:
LFF.Kabu.Win.Tabellenverwaltung.Entities.DruckUndVersand
15:15:09.296 [17] INFO NHibernate.Engine.Cascade - cascade
NHibernate.Engine.CascadingAction+SaveUpdateCascadingAction for
collection:
LFF.Kabu.Win.Tabellenverwaltung.Entities.DruckUndVersand.RefFilters
15:15:09.296 [17] DEBUG NHibernate.Engine.CascadingAction - cascading
to saveOrUpdate:
LFF.Kabu.Win.Tabellenverwaltung.Entities.RefDruckUndVersandFilter
15:15:09.296 [17] DEBUG
NHibernate.Event.Default.AbstractSaveEventListener - persistent
instance of:
LFF.Kabu.Win.Tabellenverwaltung.Entities.RefDruckUndVersandFilter
15:15:09.296 [17] DEBUG
NHibernate.Event.Default.DefaultSaveOrUpdateEventListener - ignoring
persistent instance
15:15:09.296 [17] DEBUG
NHibernate.Event.Default.DefaultSaveOrUpdateEventListener - object
already associated with session:
[LFF.Kabu.Win.Tabellenverwaltung.Entities.RefDruckUndVersandFilter#LFF.Kabu.Win.Tabellenverwaltung.Entities.RefDruckUndVersandFilter]
15:15:09.296 [17] DEBUG NHibernate.Engine.CascadingAction - cascading
to saveOrUpdate:
LFF.Kabu.Win.Tabellenverwaltung.Entities.RefDruckUndVersandFilter
15:15:09.296 [17] DEBUG
NHibernate.Event.Default.AbstractSaveEventListener - persistent
instance of:
LFF.Kabu.Win.Tabellenverwaltung.Entities.RefDruckUndVersandFilter
15:15:09.296 [17] DEBUG
NHibernate.Event.Default.DefaultSaveOrUpdateEventListener - ignoring
persistent instance
15:15:09.296 [17] DEBUG
NHibernate.Event.Default.DefaultSaveOrUpdateEventListener - object
already associated with session:
[LFF.Kabu.Win.Tabellenverwaltung.Entities.RefDruckUndVersandFilter#LFF.Kabu.Win.Tabellenverwaltung.Entities.RefDruckUndVersandFilter]
15:15:09.296 [17] INFO NHibernate.Engine.Cascade - done cascade
NHibernate.Engine.CascadingAction+SaveUpdateCascadingAction for
collection:
LFF.Kabu.Win.Tabellenverwaltung.Entities.DruckUndVersand.RefFilters
15:15:09.296 [17] INFO NHibernate.Engine.Cascade - cascade
NHibernate.Engine.CascadingAction+SaveUpdateCascadingAction for
collection:
LFF.Kabu.Win.Tabellenverwaltung.Entities.DruckUndVersand.RefDruckUndVersandAusgaben
15:15:09.296 [17] INFO NHibernate.Engine.Cascade - done cascade
NHibernate.Engine.CascadingAction+SaveUpdateCascadingAction for
collection:
LFF.Kabu.Win.Tabellenverwaltung.Entities.DruckUndVersand.RefDruckUndVersandAusgaben
15:15:09.296 [17] INFO NHibernate.Engine.Cascade - done processing
cascade NHibernate.Engine.CascadingAction+SaveUpdateCascadingAction
for: LFF.Kabu.Win.Tabellenverwaltung.Entities.DruckUndVersand
15:15:09.296 [17] DEBUG
NHibernate.Event.Default.AbstractFlushingEventListener - dirty
checking collections
15:15:09.296 [17] DEBUG
NHibernate.Event.Default.AbstractFlushingEventListener - Flushing
entities and processing referenced collections
15:15:09.296 [17] DEBUG NHibernate.Engine.Collections - Collection
found:
[LFF.Kabu.Win.Tabellenverwaltung.Entities.DruckUndVersand.RefFilters#8],
was:
[LFF.Kabu.Win.Tabellenverwaltung.Entities.DruckUndVersand.RefFilters#8]
(initialized)
15:15:09.296 [17] DEBUG NHibernate.Engine.Collections - Collection
found:
[LFF.Kabu.Win.Tabellenverwaltung.Entities.DruckUndVersand.RefDruckUndVersandAusgaben#8],
was:
[LFF.Kabu.Win.Tabellenverwaltung.Entities.DruckUndVersand.RefDruckUndVersandAusgaben#8]
(uninitialized)
15:15:09.296 [17] DEBUG NHibernate.Engine.Collections - Collection
found:
[LFF.Kabu.Win.Tabellenverwaltung.Entities.DruckUndVersand.RefFilters#1],
was:
[LFF.Kabu.Win.Tabellenverwaltung.Entities.DruckUndVersand.RefFilters#1]
(initialized)
15:15:09.296 [17] DEBUG NHibernate.Engine.Collections - Collection
found:
[LFF.Kabu.Win.Tabellenverwaltung.Entities.DruckUndVersand.RefDruckUndVersandAusgaben#1],
was:
[LFF.Kabu.Win.Tabellenverwaltung.Entities.DruckUndVersand.RefDruckUndVersandAusgaben#1]
(uninitialized)
15:15:09.296 [17] DEBUG NHibernate.Engine.Collections - Collection
found:
[LFF.Kabu.Win.Tabellenverwaltung.Entities.DruckUndVersand.RefFilters#3],
was:
[LFF.Kabu.Win.Tabellenverwaltung.Entities.DruckUndVersand.RefFilters#3]
(initialized)
15:15:09.296 [17] DEBUG NHibernate.Engine.Collections - Collection
found:
[LFF.Kabu.Win.Tabellenverwaltung.Entities.DruckUndVersand.RefDruckUndVersandAusgaben#3],
was:
[LFF.Kabu.Win.Tabellenverwaltung.Entities.DruckUndVersand.RefDruckUndVersandAusgaben#3]
(uninitialized)
15:15:09.296 [17] DEBUG
NHibernate.Event.Default.AbstractFlushingEventListener - Processing
unreferenced collections
15:15:09.296 [17] DEBUG NHibernate.Engine.Collections - Collection
dereferenced:
[LFF.Kabu.Win.Tabellenverwaltung.Entities.DruckUndVersand.RefFilters#9]
15:15:09.296 [17] DEBUG NHibernate.Engine.Collections - Collection
dereferenced:
[LFF.Kabu.Win.Tabellenverwaltung.Entities.DruckUndVersand.RefDruckUndVersandAusgaben#9]
15:15:09.296 [17] DEBUG
NHibernate.Event.Default.AbstractFlushingEventListener - Scheduling
collection removes/(re)creates/updates
15:15:09.296 [17] DEBUG
NHibernate.Event.Default.AbstractFlushingEventListener - Flushed: 0
insertions, 0 updates, 2 deletions to 8 objects
15:15:09.296 [17] DEBUG
NHibernate.Event.Default.AbstractFlushingEventListener - Flushed: 0
(re)creations, 0 updates, 2 removals to 8 collections
15:15:09.296 [17] DEBUG NHibernate.Impl.Printer - listing entities:
15:15:09.296 [17] DEBUG NHibernate.Impl.Printer -
LFF.Kabu.Win.Tabellenverwaltung.Entities.DruckUndVersand{'Id'='8',
'RefFilters'='[]', 'RefDruckUndVersandAusgaben'='<uninitialized>',
'Programm'='Datenblatt', 'Variante'='Buchungslauf',
'Beschreibung'=null, 'IsActive'='False'}
15:15:09.296 [17] DEBUG NHibernate.Impl.Printer -
LFF.Kabu.Win.Tabellenverwaltung.Entities.DruckUndVersand{'Id'='9',
'RefFilters'='['LFF.Kabu.Win.Tabellenverwaltung.Entities.RefDruckUndVersandFilter']',
'RefDruckUndVersandAusgaben'='[]', 'Programm'='Datenblatt',
'Variante'='Buchungslauf', 'Beschreibung'=null, 'IsActive'='False'}
15:15:09.296 [17] DEBUG NHibernate.Impl.Printer -
LFF.Kabu.Win.Tabellenverwaltung.Entities.DruckUndVersand{'Id'='1',
'RefFilters'='['LFF.Kabu.Win.Tabellenverwaltung.Entities.RefDruckUndVersandFilter']',
'RefDruckUndVersandAusgaben'='<uninitialized>',
'Programm'='Zahlungsanzeigen', 'Variante'='Maschinell',
'Beschreibung'=null, 'IsActive'='True'}
15:15:09.296 [17] DEBUG NHibernate.Impl.Printer -
LFF.Kabu.Win.Tabellenverwaltung.Entities.DruckUndVersand{'Id'='3',
'RefFilters'='['LFF.Kabu.Win.Tabellenverwaltung.Entities.RefDruckUndVersandFilter',
'LFF.Kabu.Win.Tabellenverwaltung.Entities.RefDruckUndVersandFilter']',
'RefDruckUndVersandAusgaben'='<uninitialized>',
'Programm'='MonatlicheKontoauszüge', 'Variante'='Maschinell',
'Beschreibung'=null, 'IsActive'='True'}
15:15:09.296 [17] DEBUG NHibernate.Impl.Printer -
LFF.Kabu.Win.Tabellenverwaltung.Entities.RefDruckUndVersandFilter{'Filter'='01'}
15:15:09.296 [17] DEBUG NHibernate.Impl.Printer -
LFF.Kabu.Win.Tabellenverwaltung.Entities.RefDruckUndVersandFilter{'Filter'='A998'}
15:15:09.296 [17] DEBUG NHibernate.Impl.Printer -
LFF.Kabu.Win.Tabellenverwaltung.Entities.RefDruckUndVersandFilter{'Filter'='01'}
15:15:09.296 [17] DEBUG NHibernate.Impl.Printer -
LFF.Kabu.Win.Tabellenverwaltung.Entities.RefDruckUndVersandFilter{'Filter'='0304'}
15:15:09.296 [17] DEBUG
NHibernate.Event.Default.AbstractFlushingEventListener - executing
flush
15:15:09.296 [17] DEBUG NHibernate.AdoNet.ConnectionManager -
registering flush begin
15:15:09.311 [17] DEBUG
NHibernate.Persister.Entity.AbstractEntityPersister - Deleting entity:
[LFF.Kabu.Win.Tabellenverwaltung.Entities.RefDruckUndVersandFilter#LFF.Kabu.Win.Tabellenverwaltung.Entities.RefDruckUndVersandFilter]
15:15:09.311 [17] DEBUG NHibernate.AdoNet.AbstractBatcher - Opened new
IDbCommand, open IDbCommands: 1
15:15:09.311 [17] DEBUG NHibernate.AdoNet.AbstractBatcher - Building
an IDbCommand object for the SqlString: DELETE FROM
REFDruckUndVersandFILTER WHERE IDDruckUndVersand = ? AND FILTERRANK
= ?
15:15:09.311 [17] DEBUG NHibernate.Type.Int64Type - binding '9' to
parameter: 0
15:15:09.311 [17] DEBUG NHibernate.Type.Int64Type - binding '1' to
parameter: 1
15:15:09.311 [17] DEBUG NHibernate.SQL - DELETE FROM
REFDruckUndVersandFILTER WHERE IDDruckUndVersand = :p0 AND FILTERRANK
= :p1;:p0 = 9 [Type: Int64 (0)], :p1 = 1 [Type: Int64 (0)]
15:15:09.311 [17] DEBUG NHibernate.Transaction.AdoTransaction - Enlist
Command
15:15:09.311 [17] DEBUG NHibernate.AdoNet.AbstractBatcher -
ExecuteNonQuery took 1 ms
15:15:09.342 [17] DEBUG NHibernate.AdoNet.ConnectionManager -
registering flush end
15:15:12.448 [17] DEBUG NHibernate.Transaction.AdoTransaction -
Rollback
15:15:12.464 [17] DEBUG NHibernate.Transaction.AdoTransaction -
IDbTransaction RolledBack
15:15:12.464 [17] DEBUG NHibernate.Transaction.AdoTransaction -
IDbTransaction disposed.
15:15:12.464 [17] DEBUG NHibernate.Impl.SessionImpl - transaction
completion
15:15:12.464 [17] DEBUG NHibernate.AdoNet.ConnectionManager -
aggressively releasing database connection
15:15:12.464 [17] DEBUG NHibernate.Connection.ConnectionProvider -
Closing connection
> > fluent-nhibern...@googlegroups.com<fluent-nhibernate%2Bunsubscr i...@googlegroups.com>
> > .

Frank

unread,
Oct 25, 2010, 3:54:18 AM10/25/10
to Fluent NHibernate
it seems that i found the problem...
the override for Equals and GetHashCode causes this error.

i changed my code and it works

public override bool Equals(object obj)
{
var toCompare = obj as RefDruckUndVersandFilter;

if (toCompare == null)
return false;

if (!GetType().Equals(toCompare.GetActualType()))
return false;

if (ReferenceEquals(this, toCompare))
return true;

return DruckUndVersand == toCompare.DruckUndVersand
&& Rank == toCompare.Rank
//&&Filter == toCompare.Filter old causes the error
;
}

protected virtual Type GetActualType()
{
return GetType();
}

public override int GetHashCode()
{
unchecked
{
var hashcode = GetType().GetHashCode();

hashcode = (hashcode * 31) ^ (DruckUndVersand !=
null ? DruckUndVersand.GetHashCode() : 0);
hashcode = (hashcode * 31) ^ Rank.GetHashCode();
//hashcode = (hashcode * 31) ^ (Filter != null ?
Filter .GetHashCode() : 0); old causes the error

return hashcode;
> not located in load context
> 15:15:09.264 [17] DEBUG
> NHibernate.Engine.Loading.CollectionLoadContext - removing collection
> load entry
> [NHibernate.Engine.Loading.LoadingCollectionEntry<rs=System.Data.OracleClie nt.OracleDataReader,
> coll=[LFF.Kabu.Win.Tabellenverwaltung.Entities.DruckUndVersand.RefDruckUndV ersandAusgaben#9]>@69a2a7]
> 15:15:09.264 [17] DEBUG
> NHibernate.Engine.Loading.CollectionLoadContext - 1 collections were
> found in result set for role:
> LFF.Kabu.Win.Tabellenverwaltung.Entities.DruckUndVersand.RefDruckUndVersand Ausgaben
> 15:15:09.264 [17] DEBUG
> NHibernate.Engine.Loading.CollectionLoadContext - ending loading
> collection ...
>
> Erfahren Sie mehr »

Michael W Powell

unread,
Jun 21, 2025, 2:57:49 PMJun 21
to Fluent NHibernate
Curious, I am finding similar issues in my parent-child, getting exceptions "could not delete collection rows" and inner "null value in column of relation violates not-null constraint", basically a child that SHOULD be removed from the parent, then deleted from the databae... A common thing to want to do IMO.

How does 'equality' have anything to do with that I wonder. Key take aways from above, curious about comparing Type with GetActualType? Why? Except perhaps there are proxies involved, but are these not base class the model? And with pattern matching does that not also sort some of that concern? i.e. 'obj is T instance' and so forth. Granted pattern matching was not there probably with the OP. But now that it is...

Also the hash code, with the type foundation and its hash code as the basis, that's interesting. Is that because Session is hashing 'all' objects in a flat collection? I could see perhaps that there would be some unintended collisions going on if one did not base it on the Type as well.

Best and thank you!

Reply all
Reply to author
Forward
0 new messages