/// <summary> Called just after the entities properties have been initialized. </summary> /// <param name="entityTuplizer">The entity tupilizer.</param> /// <param name="entity">The entity being initialized. </param> /// <param name="session">The session initializing this entity. </param> public static void AfterInitialize(this IEntityTuplizer entityTuplizer, object entity, ISessionImplementor session) { if (entityTuplizer is AbstractEntityTuplizer abstractEntityTuplizer) { abstractEntityTuplizer.AfterInitialize(entity, session); return; } #pragma warning disable 618 entityTuplizer.AfterInitialize(entity, true, session); #pragma warning restore 618 }
//6.0 TODO: Merge into IEntityTuplizer internal static ISet <string> GetUninitializedLazyProperties(this IEntityTuplizer entityTuplizer, object entity) { if (entityTuplizer is AbstractEntityTuplizer abstractEntityTuplizer) { return(abstractEntityTuplizer.GetUninitializedLazyProperties(entity)); } if (!entityTuplizer.HasUninitializedLazyProperties(entity)) { return(CollectionHelper.EmptySet <string>()); } return(null); // The caller should use all lazy properties as the result }
/// <summary> /// Instantiates a EntityEntityModeToTuplizerMapping based on the given /// entity mapping and metamodel definitions. /// </summary> /// <param name="mappedEntity">The entity mapping definition. </param> /// <param name="em">The entity metamodel definition. </param> public EntityEntityModeToTuplizerMapping(PersistentClass mappedEntity, EntityMetamodel em) { // create our own copy of the user-supplied tuplizer impl map Dictionary <EntityMode, string> userSuppliedTuplizerImpls = mappedEntity.TuplizerMap != null ? new Dictionary <EntityMode, string>( mappedEntity.TuplizerMap) : new Dictionary <EntityMode, string>(); // Build the dynamic-map tuplizer... ITuplizer dynamicMapTuplizer; string tuplizerImpl; if (!userSuppliedTuplizerImpls.TryGetValue(EntityMode.Map, out tuplizerImpl)) { dynamicMapTuplizer = new DynamicMapEntityTuplizer(em, mappedEntity); } else { dynamicMapTuplizer = BuildEntityTuplizer(tuplizerImpl, mappedEntity, em); userSuppliedTuplizerImpls.Remove(EntityMode.Map); } // then the pojo tuplizer, using the dynamic-map tuplizer if no pojo representation is available ITuplizer pojoTuplizer; string tempObject2; userSuppliedTuplizerImpls.TryGetValue(EntityMode.Poco, out tempObject2); userSuppliedTuplizerImpls.Remove(EntityMode.Poco); tuplizerImpl = tempObject2; if (mappedEntity.HasPocoRepresentation) { if (tuplizerImpl == null) { pojoTuplizer = new PocoEntityTuplizer(em, mappedEntity); } else { pojoTuplizer = BuildEntityTuplizer(tuplizerImpl, mappedEntity, em); } } else { pojoTuplizer = dynamicMapTuplizer; } // put the "standard" tuplizers into the tuplizer map first if (pojoTuplizer != null) { AddTuplizer(EntityMode.Poco, pojoTuplizer); } if (dynamicMapTuplizer != null) { AddTuplizer(EntityMode.Map, dynamicMapTuplizer); } // then handle any user-defined entity modes... foreach (KeyValuePair <EntityMode, string> pair in userSuppliedTuplizerImpls) { IEntityTuplizer tuplizer = BuildEntityTuplizer(pair.Value, mappedEntity, em); AddTuplizer(pair.Key, tuplizer); } }