OK... I've got an old Documentation then. It's for Version 1.2.0. Thought it was the actual version :)
But there's still no IsUnsaved(...) Event.
Code:
<xs:simpleType name="listenerType">
<xs:restriction base="xs:string">
<xs:enumeration value="auto-flush" />
<xs:enumeration value="merge" />
<xs:enumeration value="create" />
<xs:enumeration value="create-onflush" />
<xs:enumeration value="delete" />
<xs:enumeration value="dirty-check" />
<xs:enumeration value="evict" />
<xs:enumeration value="flush" />
<xs:enumeration value="flush-entity" />
<xs:enumeration value="load" />
<xs:enumeration value="load-collection" />
<xs:enumeration value="lock" />
<xs:enumeration value="refresh" />
<xs:enumeration value="replicate" />
<xs:enumeration value="save-update" />
<xs:enumeration value="save" />
<xs:enumeration value="pre-update" />
<xs:enumeration value="update" />
<xs:enumeration value="pre-load" />
<xs:enumeration value="pre-delete" />
<xs:enumeration value="pre-insert" />
<xs:enumeration value="post-load" />
<xs:enumeration value="post-insert" />
<xs:enumeration value="post-update" />
<xs:enumeration value="post-delete" />
<xs:enumeration value="post-commit-update" />
<xs:enumeration value="post-commit-insert" />
<xs:enumeration value="post-commit-delete" />
</xs:restriction>
</xs:simpleType>
This is the IInterceptor Interface in my Version of NHibernate:
Code:
namespace NHibernate
{
public interface IInterceptor
{
void AfterTransactionBegin(ITransaction tx);
void AfterTransactionCompletion(ITransaction tx);
void BeforeTransactionCompletion(ITransaction tx);
int[] FindDirty(object entity, object id, object[] currentState, object[] previousState, string[] propertyNames, IType[] types);
object GetEntity(string entityName, object id);
string GetEntityName(object entity);
object Instantiate(string entityName, EntityMode entityMode, object id);
//
// Zusammenfassung:
// Called when a transient entity is passed to SaveOrUpdate.
//
// Parameter:
// entity:
// A transient entity
//
// Rückgabewerte:
// Boolean or null to choose default behaviour
//
// Hinweise:
// The return value determines if the object is saved true - the entity is passed
// to Save(), resulting in an INSERT false - the entity is passed to Update(),
// resulting in an UPDATE null - Hibernate uses the unsaved-value mapping to
// determine if the object is unsaved
bool? IsTransient(object entity);
void OnCollectionRecreate(object collection, object key);
void OnCollectionRemove(object collection, object key);
void OnCollectionUpdate(object collection, object key);
void OnDelete(object entity, object id, object[] state, string[] propertyNames, IType[] types);
bool OnFlushDirty(object entity, object id, object[] currentState, object[] previousState, string[] propertyNames, IType[] types);
bool OnLoad(object entity, object id, object[] state, string[] propertyNames, IType[] types);
SqlString OnPrepareStatement(SqlString sql);
bool OnSave(object entity, object id, object[] state, string[] propertyNames, IType[] types);
void SetSession(ISession session);
}
}
I left the documentation to IsTransient(...), because I think this matches the IsUnsaved function. Maybe you can do something like:
Code:
bool? IsTransient(object entity)
{
if( entity.getType() == typeof(VirtualTeststepData) )
{
//Use another Session to determine if the instance is already in DB
if( IsInDB )
return true;
else
return false;
}
else
return null;
}
Though I assume this would not be very performant if you do a lot of changes to different VirtualTeststepDatas.