/// <summary> /// Called just before an object is initialized /// </summary> /// <param name="entity"></param> /// <param name="id"></param> /// <param name="propertyNames"></param> /// <param name="state"></param> /// <param name="types"></param> /// <remarks> /// The interceptor may change the <c>state</c>, which will be propagated to the persistent /// object. Note that when this method is called, <c>entity</c> will be an empty /// uninitialized instance of the class.</remarks> /// <returns><c>true</c> if the user modified the <c>state</c> in any way</returns> public override bool OnLoad(object entity, object id, object[] state, string[] propertyNames, IType[] types) { ActiveRecordHooksBase hookTarget = entity as ActiveRecordHooksBase; if (hookTarget != null) { return(hookTarget.BeforeLoad(id, new DictionaryAdapter(propertyNames, state))); } return(false); }
/// <summary> /// Called from <c>Flush()</c>. The return value determines whether the entity is updated /// </summary> /// <remarks> /// <list> /// <item>an array of property indicies - the entity is dirty</item> /// <item>an empty array - the entity is not dirty</item> /// <item><c>null</c> - use Hibernate's default dirty-checking algorithm</item> /// </list> /// </remarks> /// <param name="entity">A persistent entity</param> /// <param name="currentState"></param> /// <param name="id"></param> /// <param name="previousState"></param> /// <param name="propertyNames"></param> /// <param name="types"></param> /// <returns>An array of dirty property indicies or <c>null</c> to choose default behavior</returns> public override int[] FindDirty(object entity, object id, object[] currentState, object[] previousState, string[] propertyNames, IType[] types) { ActiveRecordHooksBase hookTarget = entity as ActiveRecordHooksBase; if (hookTarget != null) { return(hookTarget.FindDirty(id, new DictionaryAdapter(propertyNames, previousState), new DictionaryAdapter(propertyNames, currentState), types)); } return(null); }
/// <summary> /// Called when a transient entity is passed to <c>SaveOrUpdate</c>. /// </summary> /// <remarks> /// The return value determines if the object is saved /// <list> /// <item><see langword="true" /> - the entity is passed to <c>Save()</c>, resulting in an <c>INSERT</c></item> /// <item><see langword="false" /> - the entity is passed to <c>Update()</c>, resulting in an <c>UPDATE</c></item> /// <item><see langword="null" /> - Hibernate uses the <c>unsaved-value</c> mapping to determine if the object is unsaved</item> /// </list> /// </remarks> /// <param name="entity">A transient entity</param> /// <returns>Boolean or <see langword="null" /> to choose default behaviour</returns> public override bool?IsTransient(object entity) { ActiveRecordHooksBase hookTarget = entity as ActiveRecordHooksBase; if (hookTarget != null) { return(hookTarget.IsUnsaved()); } return(null); }
/// <summary> /// Called after a flush that actually ends in execution of the SQL statements required to /// synchronize in-memory state with the database. /// </summary> /// <param name="entities">The entitites</param> public override void PostFlush(ICollection entities) { foreach (object entity in entities) { ActiveRecordHooksBase hookTarget = entity as ActiveRecordHooksBase; if (hookTarget != null) { hookTarget.PostFlush(); } } }