/// <summary> /// Generates an identifer from the value of a Property. /// </summary> /// <param name="session">The <see cref="ISessionImplementor"/> this id is being generated in.</param> /// <param name="obj">The entity for which the id is being generated.</param> /// <returns> /// The identifier value from the associated object or /// <see cref="IdentifierGeneratorFactory.ShortCircuitIndicator"/> if the <c>session</c> /// already contains <c>obj</c>. /// </returns> public object Generate( ISessionImplementor session, object obj ) { object associatedObject = session.Factory .GetClassMetadata( obj.GetType() ) .GetPropertyValue( obj, propertyName ); object id = session.Save( associatedObject ); if( session.Contains( obj ) ) { //abort the save (the object is already saved by a circular cascade) return IdentifierGeneratorFactory.ShortCircuitIndicator; } return id; }
/// <summary> /// Generates an identifer from the value of a Property. /// </summary> /// <param name="session">The <see cref="ISessionImplementor"/> this id is being generated in.</param> /// <param name="obj">The entity for which the id is being generated.</param> /// <returns> /// The identifier value from the associated object or /// <see cref="IdentifierGeneratorFactory.ShortCircuitIndicator"/> if the <c>session</c> /// already contains <c>obj</c>. /// </returns> public object Generate(ISessionImplementor session, object obj) { object associatedObject = session.Factory .GetClassMetadata(obj.GetType()) .GetPropertyValue(obj, propertyName); object id = session.Save(associatedObject); if (session.Contains(obj)) { //abort the save (the object is already saved by a circular cascade) return(IdentifierGeneratorFactory.ShortCircuitIndicator); } return(id); }