/// <summary> /// Hydrate the state of an object from the SQL <c>IDataReader</c>, into /// an array of "hydrated" values (do not resolve associations yet), /// and pass the hydrated state to the session. /// </summary> /// <param name="rs"></param> /// <param name="i"></param> /// <param name="obj"></param> /// <param name="key"></param> /// <param name="suffix"></param> /// <param name="lockMode"></param> /// <param name="rootPersister"></param> /// <param name="session"></param> private void LoadFromResultSet( IDataReader rs, int i, object obj, Key key, string suffix, LockMode lockMode, ILoadable rootPersister, ISessionImplementor session ) { if( log.IsDebugEnabled ) { log.Debug( "Initializing object from DataReader: " + key ); } // add temp entry so that the next step is circular-reference // safe - only needed because some types don't take proper // advantage of two-phase-load (esp. components) session.AddUninitializedEntity( key, obj, lockMode ); // Get the persister for the _subclass_ ILoadable persister = ( ILoadable ) session.GetPersister( obj ); // This is not very nice (and quite slow): string[ ][ ] cols = persister == rootPersister ? suffixedPropertyColumns[ i ] : GetSuffixedPropertyAliases( persister, suffix ); object id = key.Identifier; object[ ] values = Hydrate( rs, id, obj, persister, session, cols ); session.PostHydrate( persister, id, values, obj, lockMode ); }
public object Load(object id, object optionalObject, LockMode lockMode, ISessionImplementor session) { Custom clone = null; Custom obj = (Custom) Instances[id]; if(obj!=null) { clone = (Custom)obj.Clone(); session.AddUninitializedEntity( new Key(id, this), clone, LockMode.None ); session.PostHydrate( this, id, new string[] {obj.Name}, clone, LockMode.None ); session.InitializeEntity(clone); } return clone; }
/// <summary> /// Hydrate the state of an object from the SQL <c>IDataReader</c>, into /// an array of "hydrated" values (do not resolve associations yet), /// and pass the hydrated state to the session. /// </summary> private void LoadFromResultSet( IDataReader rs, int i, object obj, System.Type instanceClass, EntityKey key, LockMode lockMode, ILoadable rootPersister, ISessionImplementor session) { object id = key.Identifier; // Get the persister for the _subclass_ ILoadable persister = (ILoadable) Factory.GetEntityPersister(instanceClass); if (log.IsDebugEnabled) { log.Debug("Initializing object from DataReader: " + MessageHelper.InfoString(persister, id)); } // add temp entry so that the next step is circular-reference // safe - only needed because some types don't take proper // advantage of two-phase-load (esp. components) session.AddUninitializedEntity(key, obj, lockMode); // This is not very nice (and quite slow): string[][] cols = persister == rootPersister ? EntityAliases[i].SuffixedPropertyAliases : EntityAliases[i].GetSuffixedPropertyAliases(persister); object[] values = Hydrate( rs, id, obj, persister, session, cols); // TODO H3: // IAssociationType[] ownerAssociationTypes = OwnerAssociationTypes; // // if ( ownerAssociationTypes != null && ownerAssociationTypes[i] != null ) // { // string ukName = ownerAssociationTypes[i].RHSUniqueKeyPropertyName; // if (ukName!=null) // { // int index = ( (IUniqueKeyLoadable) persister ).GetPropertyIndex(ukName); // IType type = persister.PropertyTypes[index]; // // // polymorphism not really handled completely correctly, // // perhaps...well, actually its ok, assuming that the // // entity name used in the lookup is the same as the // // the one used here, which it will be // // EntityUniqueKey euk = new EntityUniqueKey( // rootPersister.MappedClass, //polymorphism comment above // ukName, // type.SemiResolve( values[ index ], session, obj ), // type, // session.EntityMode, session.Factory // ); // session.AddEntity( euk, obj ); // } // } session.PostHydrate(persister, id, values, obj, lockMode); }