public CompositeElementPropertyMapping(string[] elementColumns, string[] elementFormulaTemplates, IAbstractComponentType compositeType, IMapping factory) { this.compositeType = compositeType; InitComponentPropertyPaths(null, compositeType, elementColumns, elementFormulaTemplates, factory); }
public void PostInstantiate(string entityName, Type persistentClass, ISet<Type> interfaces, MethodInfo getIdentifierMethod, MethodInfo setIdentifierMethod, IAbstractComponentType componentIdType) { _entityName = entityName; _persistentClass = persistentClass; _interfaces = new Type[interfaces.Count]; interfaces.CopyTo(_interfaces, 0); _getIdentifierMethod = getIdentifierMethod; _setIdentifierMethod = setIdentifierMethod; _componentIdType = componentIdType; _isClassProxy = _interfaces.Length == 1; _proxyKey = entityName; if( _proxies.Contains(_proxyKey) ) { _proxyType = _proxies[_proxyKey] as Type; _log.DebugFormat("Using proxy type '{0}' for persistent class '{1}'", _proxyType.Name, _persistentClass.FullName); } else { string message = string.Format("No proxy type found for persistent class '{0}' using proxy key '{1}'", _persistentClass.FullName, _proxyKey); _log.Error(message); throw new HibernateException(message); } }
///<summary> ///</summary> ///<param name="entityName"></param> ///<param name="persistentClass"></param> ///<param name="id"></param> ///<param name="getIdentifierMethod"></param> ///<param name="setIdentifierMethod"></param> ///<param name="componentIdType"></param> ///<param name="session"></param> public LazyInitializer(string entityName, Type persistentClass, object id, MethodInfo getIdentifierMethod, MethodInfo setIdentifierMethod, IAbstractComponentType componentIdType, ISessionImplementor session) : base(entityName, persistentClass, id, getIdentifierMethod, setIdentifierMethod, componentIdType, session) { }
/// <summary> /// Visit a component. Dispatch each property to <see cref="ProcessValues"/> /// </summary> /// <param name="component"></param> /// <param name="componentType"></param> /// <returns></returns> internal virtual object ProcessComponent(object component, IAbstractComponentType componentType) { if (component != null) { ProcessValues(componentType.GetPropertyValues(component, session), componentType.Subtypes); } return null; }
/// <summary> Constructs a new AbstractEntityTuplizer instance. </summary> /// <param name="entityMetamodel">The "interpreted" information relating to the mapped entity. </param> /// <param name="mappingInfo">The parsed "raw" mapping data relating to the given entity. </param> protected AbstractEntityTuplizer(EntityMetamodel entityMetamodel, PersistentClass mappingInfo) { this.entityMetamodel = entityMetamodel; if (!entityMetamodel.IdentifierProperty.IsVirtual) { idGetter = BuildPropertyGetter(mappingInfo.IdentifierProperty, mappingInfo); idSetter = BuildPropertySetter(mappingInfo.IdentifierProperty, mappingInfo); } else { idGetter = null; idSetter = null; } propertySpan = entityMetamodel.PropertySpan; getters = new IGetter[propertySpan]; setters = new ISetter[propertySpan]; bool foundCustomAccessor = false; int i = 0; foreach (Mapping.Property property in mappingInfo.PropertyClosureIterator) { getters[i] = BuildPropertyGetter(property, mappingInfo); setters[i] = BuildPropertySetter(property, mappingInfo); if (!property.IsBasicPropertyAccessor) foundCustomAccessor = true; i++; } if (log.IsDebugEnabled) { log.DebugFormat("{0} accessors found for entity: {1}", foundCustomAccessor ? "Custom" : "No custom", mappingInfo.EntityName); } hasCustomAccessors = foundCustomAccessor; //NH-1587 //instantiator = BuildInstantiator(mappingInfo); if (entityMetamodel.IsLazy) { proxyFactory = BuildProxyFactory(mappingInfo, idGetter, idSetter); if (proxyFactory == null) { entityMetamodel.IsLazy = false; } } else { proxyFactory = null; } Mapping.Component mapper = mappingInfo.IdentifierMapper; identifierMapperType = mapper == null ? null : (IAbstractComponentType)mapper.Type; }
protected internal BasicLazyInitializer(string entityName, System.Type persistentClass, object id, MethodInfo getIdentifierMethod, MethodInfo setIdentifierMethod, IAbstractComponentType componentIdType, ISessionImplementor session) : base(entityName, id, session) { this.persistentClass = persistentClass; this.getIdentifierMethod = getIdentifierMethod; this.setIdentifierMethod = setIdentifierMethod; this.componentIdType = componentIdType; overridesEquals = ReflectHelper.OverridesEquals(persistentClass); }
public virtual void PostInstantiate(string entityName, System.Type persistentClass, ISet<System.Type> interfaces, MethodInfo getIdentifierMethod, MethodInfo setIdentifierMethod, IAbstractComponentType componentIdType) { _entityName = entityName; _persistentClass = persistentClass; _interfaces = new System.Type[interfaces.Count]; interfaces.CopyTo(_interfaces, 0); _getIdentifierMethod = getIdentifierMethod; _setIdentifierMethod = setIdentifierMethod; _componentIdType = componentIdType; }
public PropertyChangedLazyInitializer( string entityName, Type persistentClass, object id, MethodInfo getIdentifierMethod, MethodInfo setIdentifierMethod, IAbstractComponentType componentIdType, ISessionImplementor session, bool entityHandlesPropertyChanged) : base(entityName, persistentClass, id, getIdentifierMethod, setIdentifierMethod, componentIdType, session) { _entityHandlesPropertyChanged = entityHandlesPropertyChanged; }
internal override object ProcessComponent(object component, IAbstractComponentType componentType) { IType[] types = componentType.Subtypes; if (component == null) { ProcessValues(new object[types.Length], types); } else { base.ProcessComponent(component, componentType); } return null; }
public void PostInstantiate(string entityName, System.Type persistentClass, ISet<System.Type> interfaces, MethodInfo getIdentifierMethod, MethodInfo setIdentifierMethod, IAbstractComponentType componentIdType) { if (persistentClass.IsGenericType) return; var interfacesCount = interfaces.Count; var ifaces = new System.Type[interfacesCount]; if (interfacesCount > 0) interfaces.CopyTo(ifaces, 0); var proxyType = ifaces.Length == 1 ? factory.CreateProxyType(persistentClass, ifaces) : factory.CreateProxyType(ifaces[0], ifaces); proxies[entityName] = proxyType; }
public virtual void PostInstantiate(string entityName, System.Type persistentClass, ISet<System.Type> interfaces, MethodInfo getIdentifierMethod, MethodInfo setIdentifierMethod, IAbstractComponentType componentIdType) { EntityName = entityName; PersistentClass = persistentClass; Interfaces = new System.Type[interfaces.Count]; if (interfaces.Count > 0) { interfaces.CopyTo(Interfaces, 0); } GetIdentifierMethod = getIdentifierMethod; SetIdentifierMethod = setIdentifierMethod; ComponentIdType = componentIdType; }
public void PostInstantiate(string entityName, Type persistentClass, ISet<Type> interfaces, MethodInfo getIdentifierMethod, MethodInfo setIdentifierMethod, IAbstractComponentType componentIdType) { if (persistentClass.IsGenericType) return; int interfacesCount = interfaces.Count; bool isClassProxy = interfacesCount == 1; Type[] ifaces = new Type[interfacesCount]; interfaces.CopyTo(ifaces, 0); Type proxyType; if (isClassProxy) { proxyType = _proxyBuilder.CreateClassProxy(persistentClass, ifaces, ProxyGenerationOptions.Default); } else { proxyType = _proxyBuilder.CreateInterfaceProxyTypeWithoutTarget(ifaces[0], ifaces, ProxyGenerationOptions.Default); } _proxies[entityName] = proxyType; }
internal override object ProcessComponent(object component, IAbstractComponentType componentType) { if (component != null) { object[] values = componentType.GetPropertyValues(component, Session); IType[] types = componentType.Subtypes; bool substituteComponent = false; for (int i = 0; i < types.Length; i++) { System.Object result = ProcessValue(values[i], types[i]); if (result != null) { values[i] = result; substituteComponent = true; } } if (substituteComponent) { componentType.SetPropertyValues(component, values, Session.EntityMode); } } return null; }
protected void AddComponentTypedValues(string path, object component, IAbstractComponentType type, IList list, ICriteria criteria, ICriteriaQuery criteriaQuery) { if (component != null) { string[] propertyNames = type.PropertyNames; IType[] subtypes = type.Subtypes; object[] values = type.GetPropertyValues(component, GetEntityMode(criteria, criteriaQuery)); for (int i = 0; i < propertyNames.Length; i++) { object value = values[i]; IType subtype = subtypes[i]; string subpath = StringHelper.Qualify(path, propertyNames[i]); if (IsPropertyIncluded(value, subpath, subtype)) { if (subtype.IsComponentType) { AddComponentTypedValues(subpath, value, (IAbstractComponentType) subtype, list, criteria, criteriaQuery); } else { AddPropertyTypedValue(value, subtype, list); } } } } }
protected override object ProcessComponent(object component, IAbstractComponentType componentType) { if (component == null) { return null; } object[] values = componentType.GetPropertyValues(component, Session); IType[] types = componentType.Subtypes; bool substituteComponent = false; for (int i = 0; i < types.Length; i++) { object result = ProcessValue(values[i], types[i]); if (result != null) { substituteComponent = true; values[i] = result; } } if (substituteComponent) { componentType.SetPropertyValues(component, values); } return null; }
public void PostInstantiate(string entityName, System.Type persistentClass, ISet<System.Type> interfaces, MethodInfo getIdentifierMethod, MethodInfo setIdentifierMethod, IAbstractComponentType componentIdType) { this.entityName = entityName; }
protected void AppendComponentCondition( String path, object component, IAbstractComponentType type, System.Type persistentClass, String alias, IDictionary aliasClasses, ISessionFactoryImplementor sessionFactory, SqlStringBuilder builder) { if( component != null ) { String[] propertyNames = type.PropertyNames; object[] values = type.GetPropertyValues( component, null ); IType[] subtypes = type.Subtypes; for( int i = 0; i < propertyNames.Length; i++ ) { String subpath = StringHelper.Qualify( path, propertyNames[ i ] ); object value = values[ i ]; if( IsPropertyIncluded( value, subpath, subtypes[ i ] ) ) { IType subtype = subtypes[ i ]; if( subtype.IsComponentType ) { AppendComponentCondition( subpath, value, (IAbstractComponentType)subtype, persistentClass, alias, aliasClasses, sessionFactory, builder ); } else { AppendPropertyCondition( subpath, value, persistentClass, alias, aliasClasses, sessionFactory, builder ); } } } } }
/// <summary> /// For a component, add to a list of associations to be fetched by outerjoin /// </summary> private void WalkComponentTree(IAbstractComponentType componentType, int propertyNumber, int begin, IOuterJoinLoadable persister, string alias, string path, int currentDepth) { IType[] types = componentType.Subtypes; string[] propertyNames = componentType.PropertyNames; for (int i = 0; i < types.Length; i++) { if (types[i].IsAssociationType) { IAssociationType associationType = (IAssociationType)types[i]; string[] aliasedLhsColumns = JoinHelper.GetAliasedLHSColumnNames(associationType, alias, propertyNumber, begin, persister, Factory); string[] lhsColumns = JoinHelper.GetLHSColumnNames(associationType, propertyNumber, begin, persister, Factory); string lhsTable = JoinHelper.GetLHSTableName(associationType, propertyNumber, persister); string subpath = SubPath(path, propertyNames[i]); bool[] propertyNullability = componentType.PropertyNullability; JoinType joinType = GetJoinType(associationType, componentType.GetFetchMode(i), subpath, lhsTable, lhsColumns, propertyNullability == null || propertyNullability[i], currentDepth, componentType.GetCascadeStyle(i)); AddAssociationToJoinTreeIfNecessary(associationType, aliasedLhsColumns, alias, subpath, currentDepth, joinType); } else if (types[i].IsComponentType) { string subpath = SubPath(path, propertyNames[i]); WalkComponentTree((IAbstractComponentType)types[i], propertyNumber, begin, persister, alias, subpath, currentDepth); } begin += types[i].GetColumnSpan(Factory); } }
/// <summary> Constructs a new AbstractEntityTuplizer instance. </summary> /// <param name="entityMetamodel">The "interpreted" information relating to the mapped entity. </param> /// <param name="mappingInfo">The parsed "raw" mapping data relating to the given entity. </param> public AbstractEntityTuplizer(EntityMetamodel entityMetamodel, PersistentClass mappingInfo) { this.entityMetamodel = entityMetamodel; if (!entityMetamodel.IdentifierProperty.IsVirtual) { idGetter = BuildPropertyGetter(mappingInfo.IdentifierProperty, mappingInfo); idSetter = BuildPropertySetter(mappingInfo.IdentifierProperty, mappingInfo); } else { idGetter = null; idSetter = null; } propertySpan = entityMetamodel.PropertySpan; getters = new IGetter[propertySpan]; setters = new ISetter[propertySpan]; bool foundCustomAccessor = false; int i = 0; foreach (Mapping.Property property in mappingInfo.PropertyClosureIterator) { getters[i] = BuildPropertyGetter(property, mappingInfo); setters[i] = BuildPropertySetter(property, mappingInfo); if (!property.IsBasicPropertyAccessor) foundCustomAccessor = true; i++; } if (log.IsDebugEnabled) { log.DebugFormat("{0} accessors found for entity: {1}", foundCustomAccessor ? "Custom" : "No custom", mappingInfo.EntityName); } hasCustomAccessors = foundCustomAccessor; instantiator = BuildInstantiator(mappingInfo); if (entityMetamodel.IsLazy) { /* NH Different implementation * When we are using an interface we need to use the interface itself to have * the getter and setter of the identifier to prevent proxy initialization. * The BasicLazyInitializer use method.Equals to recognize the the identifier setter. */ IGetter pidGetter = idGetter; ISetter pidSetter = idSetter; if (mappingInfo.HasIdentifierProperty && mappingInfo.ProxyInterface != null) { pidGetter = mappingInfo.IdentifierProperty.GetGetter(mappingInfo.ProxyInterface); pidSetter = mappingInfo.IdentifierProperty.GetSetter(mappingInfo.ProxyInterface); } proxyFactory = BuildProxyFactory(mappingInfo, pidGetter, pidSetter); /*******************************************************************************/ if (proxyFactory == null) { entityMetamodel.IsLazy = false; } } else { proxyFactory = null; } Mapping.Component mapper = mappingInfo.IdentifierMapper; identifierMapperType = mapper == null ? null : (IAbstractComponentType)mapper.Type; }
private static bool ProcessMembersMetadataResult( MemberMetadataResult metadataResult, ISessionFactoryImplementor sessionFactory, out IType mappedType, out IEntityPersister entityPersister, out IAbstractComponentType component, out string memberPath) { if (!TryGetEntityPersister(metadataResult.EntityName, null, sessionFactory, out var currentEntityPersister)) { // Failed to find the starting entity name, due to: // - Querying a type that is not related to any entity e.g. s.Query<NotRelatedType>().Where(a => a.Type == "A") memberPath = null; mappedType = null; entityPersister = null; component = null; return(false); } if (metadataResult.MemberPaths.Count == 0) // The expression do not contain any member expressions { if (metadataResult.ConvertType != null) { mappedType = TryGetEntityPersister( currentEntityPersister, metadataResult.ConvertType, sessionFactory, out var convertPersister) ? convertPersister.EntityMetamodel.EntityType // ((Subclass)q) : TypeFactory.GetDefaultTypeFor(metadataResult.ConvertType); // ((NotMapped)q) } else { mappedType = currentEntityPersister.EntityMetamodel.EntityType; // q } memberPath = null; component = null; entityPersister = currentEntityPersister; return(mappedType != null); } // If there was a cast right after the constant expression that contains the IEntityNameProvider instance, we have // to update the entity persister according to it, otherwise use the value returned by TryGetAllMemberMetadata method. if (metadataResult.ConvertType != null) { if (!TryGetEntityPersister( currentEntityPersister, metadataResult.ConvertType, sessionFactory, out var convertPersister)) // ((NotMapped)q).Id { memberPath = null; mappedType = null; entityPersister = null; component = null; return(false); } currentEntityPersister = convertPersister; // ((Subclass)q).Id } return(TraverseMembers( sessionFactory, metadataResult.MemberPaths, currentEntityPersister, out mappedType, out entityPersister, out component, out memberPath)); }
/// <summary> /// For a composite element, add to a list of associations to be fetched by outerjoin /// </summary> private void WalkCompositeElementTree(IAbstractComponentType compositeType, string[] cols, IQueryableCollection persister, string alias, string path, int currentDepth) { IType[] types = compositeType.Subtypes; string[] propertyNames = compositeType.PropertyNames; int begin = 0; for (int i = 0; i < types.Length; i++) { int length = types[i].GetColumnSpan(factory); string[] lhsColumns = ArrayHelper.Slice(cols, begin, length); if (types[i].IsAssociationType) { IAssociationType associationType = types[i] as IAssociationType; // simple, because we can't have a one-to-one or collection // (or even a property-ref) in a composite element: string[] aliasedLhsColumns = StringHelper.Qualify(alias, lhsColumns); string subpath = SubPath(path, propertyNames[i]); bool[] propertyNullability = compositeType.PropertyNullability; JoinType joinType = GetJoinType(associationType, compositeType.GetFetchMode(i), subpath, persister.TableName, lhsColumns, propertyNullability == null || propertyNullability[i], currentDepth, compositeType.GetCascadeStyle(i)); AddAssociationToJoinTreeIfNecessary(associationType, aliasedLhsColumns, alias, subpath, currentDepth, joinType); } else if (types[i].IsComponentType) { string subpath = SubPath(path, propertyNames[i]); WalkCompositeElementTree((IAbstractComponentType)types[i], lhsColumns, persister, alias, subpath, currentDepth); } begin += length; } }
/// <summary> /// For a component, add to a list of associations to be fetched by outerjoin /// </summary> /// <param name="componentType"></param> /// <param name="propertyNumber"></param> /// <param name="cols"></param> /// <param name="persister"></param> /// <param name="alias"></param> /// <param name="associations"></param> /// <param name="visitedPersisters"></param> /// <param name="aliasedCols"></param> /// <param name="path"></param> /// <param name="currentDepth"></param> /// <param name="factory"></param> private void WalkComponentTree( IAbstractComponentType componentType, int propertyNumber, string[ ] cols, string[ ] aliasedCols, IOuterJoinLoadable persister, string alias, IList associations, ISet visitedPersisters, string path, int currentDepth, ISessionFactoryImplementor factory ) { IType[ ] types = componentType.Subtypes; string[ ] propertyNames = componentType.PropertyNames; int begin = 0; for( int i = 0; i < types.Length; i++ ) { int length = types[ i ].GetColumnSpan( factory ); string[ ] range = ArrayHelper.Slice( cols, begin, length ); string[ ] aliasedRange = ArrayHelper.Slice( aliasedCols, begin, length ); if( types[ i ].IsAssociationType ) { IAssociationType associationType = ( IAssociationType ) types[ i ]; if ( IsJoinedFetchAlwaysDisabled( persister, associationType, propertyNumber ) ) { return; } string[] aliasedFkColumns = GetAliasedForeignKeyColumns( persister, alias, associationType, aliasedRange ); string[] fkColumns = GetForeignKeyColumns( persister, associationType, range ); string subpath = SubPath( path, propertyNames[ i ] ); JoinType joinType = GetJoinType( associationType, componentType.EnableJoinedFetch( i ), subpath, persister.GetSubclassPropertyTableName( propertyNumber ), fkColumns, factory ); if ( joinType != JoinType.None ) { WalkAssociationTree( associationType, aliasedFkColumns, persister, alias, associations, visitedPersisters, subpath, currentDepth, joinType, factory ); } } else if( types[ i ].IsComponentType ) { string subpath = SubPath( path, propertyNames[ i ] ); WalkComponentTree( ( IAbstractComponentType ) types[ i ], propertyNumber, range, aliasedRange, persister, alias, associations, visitedPersisters, subpath, currentDepth, factory ); } begin += length; } }
/// <summary> /// /// </summary> /// <param name="elementColumns"></param> /// <param name="compositeType"></param> /// <param name="factory"></param> public CompositeElementPropertyMapping( string[] elementColumns, IAbstractComponentType compositeType, ISessionFactoryImplementor factory ) { this.compositeType = compositeType; InitComponentPropertyPaths( null, compositeType, elementColumns, factory ); }
public DefaultLazyInitializer(string entityName, System.Type persistentClass, object id, MethodInfo getIdentifierMethod, MethodInfo setIdentifierMethod, IAbstractComponentType componentIdType, ISessionImplementor session, bool overridesEquals) : base(entityName, persistentClass, id, getIdentifierMethod, setIdentifierMethod, componentIdType, session, overridesEquals) {}
/// <summary> /// For a composite element, add to a list of associations to be fetched by outerjoin /// </summary> /// <param name="compositeType"></param> /// <param name="cols"></param> /// <param name="persister"></param> /// <param name="alias"></param> /// <param name="associations"></param> /// <param name="visitedPersisters"></param> /// <param name="path"></param> /// <param name="currentDepth"></param> /// <param name="factory"></param> private void WalkCompositeElementTree( IAbstractComponentType compositeType, string[ ] cols, IQueryableCollection persister, string alias, IList associations, ISet visitedPersisters, string path, int currentDepth, ISessionFactoryImplementor factory ) { IType[ ] types = compositeType.Subtypes; string[ ] propertyNames = compositeType.PropertyNames; int begin = 0; for( int i = 0; i < types.Length; i++ ) { int length = types[ i ].GetColumnSpan( factory ); string[ ] range = ArrayHelper.Slice( cols, begin, length ); if( types[ i ].IsAssociationType ) { IAssociationType associationType = types[ i ] as IAssociationType; // simple, because we can't have a one-to-one or collection in a composite element: string[] aliasedForeignKeyColumns = StringHelper.Qualify( alias, range ); string subpath = SubPath( path, propertyNames[ i ] ); JoinType joinType = GetJoinType( associationType, compositeType.EnableJoinedFetch( i ), subpath, persister.TableName, range, factory ); if ( joinType != JoinType.None ) { WalkAssociationTree( associationType, aliasedForeignKeyColumns, persister, alias, associations, visitedPersisters, subpath, currentDepth, joinType, factory ); } } else if( types[ i ].IsComponentType ) { string subpath = SubPath( path, propertyNames[ i ] ); WalkCompositeElementTree( ( IAbstractComponentType ) types[ i ], range, persister, alias, associations, visitedPersisters, subpath, currentDepth, factory ); } begin += length; } }
public DataBindingInterceptor(String EntityName, Type persistentClass, object id, MethodInfo getIdentifierMethod, MethodInfo setIdentifierMethod, IAbstractComponentType aType, ISessionImplementor session) : base(EntityName, persistentClass, id, getIdentifierMethod, setIdentifierMethod, aType, session) { }
private static bool TraverseMembers( ISessionFactoryImplementor sessionFactory, Stack <MemberMetadata> memberPaths, IEntityPersister currentEntityPersister, out IType mappedType, out IEntityPersister entityPersister, out IAbstractComponentType component, out string memberPath) { // Traverse the members that were traversed by the TryGetAllMemberMetadata method in the reverse order and try to keep // tracking the entity persister until all members are traversed. var member = memberPaths.Pop(); var currentType = currentEntityPersister.EntityMetamodel.GetPropertyType(member.Path); IAbstractComponentType currentComponentType = null; while (memberPaths.Count > 0 && currentType != null) { memberPath = member.Path; var convertType = member.ConvertType; member = memberPaths.Pop(); switch (currentType) { case IAssociationType associationType: ProcessAssociationType( associationType, sessionFactory, member, convertType, out currentType, out currentEntityPersister, out currentComponentType); break; case IAbstractComponentType componentType: currentComponentType = componentType; if (currentEntityPersister == null) { // When persister is not available (q.OneToManyCompositeElement[0].Prop), try to get the type from the component currentType = TryGetComponentPropertyType(componentType, member.Path); } else { // Concatenate the component property path in order to be able to use EntityMetamodel.GetPropertyType to retrieve the type. // As GetPropertyType supports only components, do not concatenate when dealing with collection composite elements or elements. // q.Component.Prop member = new MemberMetadata( $"{memberPath}.{member.Path}", member.ConvertType, member.HasIndexer); // q.Component.Prop currentType = currentEntityPersister.EntityMetamodel.GetPropertyType(member.Path); } break; default: // q.Prop.NotMappedProp currentType = null; currentEntityPersister = null; currentComponentType = null; break; } } // When traversed to the top of the expression, return the current tracking values if (memberPaths.Count == 0) { memberPath = currentEntityPersister != null || currentComponentType != null ? member.Path : null; mappedType = GetType(currentEntityPersister, currentType, member, sessionFactory); entityPersister = currentEntityPersister; component = currentComponentType; return(mappedType != null); } // Member not mapped memberPath = null; mappedType = null; entityPersister = null; component = null; return(false); }
protected void AppendComponentCondition( String path, object component, IAbstractComponentType type, ICriteria criteria, ICriteriaQuery criteriaQuery, IDictionary<string, IFilter> enabledFilters, SqlStringBuilder builder) { if (component != null) { String[] propertyNames = type.PropertyNames; object[] values = type.GetPropertyValues(component, GetEntityMode(criteria, criteriaQuery)); IType[] subtypes = type.Subtypes; for (int i = 0; i < propertyNames.Length; i++) { String subpath = StringHelper.Qualify(path, propertyNames[i]); object value = values[i]; if (IsPropertyIncluded(value, subpath, subtypes[i])) { IType subtype = subtypes[i]; if (subtype.IsComponentType) { AppendComponentCondition( subpath, value, (IAbstractComponentType) subtype, criteria, criteriaQuery, enabledFilters, builder); } else { AppendPropertyCondition( subpath, value, criteria, criteriaQuery, enabledFilters, builder ); } } } } }
private void CascadeComponent(object child, IAbstractComponentType componentType, object anything) { object[] children = componentType.GetPropertyValues(child, eventSource); IType[] types = componentType.Subtypes; for (int i = 0; i < types.Length; i++) { CascadeStyle componentPropertyStyle = componentType.GetCascadeStyle(i); if (componentPropertyStyle.DoCascade(action)) { CascadeProperty(children[i], types[i], componentPropertyStyle, anything, false); } } }
/// <summary> /// For a component, add to a list of associations to be fetched by outerjoin /// </summary> protected void WalkComponentTree(IAbstractComponentType componentType, int begin, string alias, string path, int currentDepth, ILhsAssociationTypeSqlInfo associationTypeSQLInfo) { IType[] types = componentType.Subtypes; string[] propertyNames = componentType.PropertyNames; for (int i = 0; i < types.Length; i++) { if (types[i].IsAssociationType) { var associationType = (IAssociationType) types[i]; string[] aliasedLhsColumns = associationTypeSQLInfo.GetAliasedColumnNames(associationType, begin); string[] lhsColumns = associationTypeSQLInfo.GetColumnNames(associationType, begin); string lhsTable = associationTypeSQLInfo.GetTableName(associationType); string subpath = SubPath(path, propertyNames[i]); bool[] propertyNullability = componentType.PropertyNullability; JoinType joinType = GetJoinType(associationType, componentType.GetFetchMode(i), subpath, lhsTable, lhsColumns, propertyNullability == null || propertyNullability[i], currentDepth, componentType.GetCascadeStyle(i)); AddAssociationToJoinTreeIfNecessary(associationType, aliasedLhsColumns, alias, subpath, currentDepth, joinType); } else if (types[i].IsComponentType) { string subpath = SubPath(path, propertyNames[i]); WalkComponentTree((IAbstractComponentType) types[i], begin, alias, subpath, currentDepth, associationTypeSQLInfo); } begin += types[i].GetColumnSpan(Factory); } }
/// <summary> /// Check component nullability. Returns property path that break /// nullability or null if none /// </summary> /// <param name="value">component properties </param> /// <param name="compType">component not-nullable type </param> /// <returns> property path </returns> private string CheckComponentNullability(object value, IAbstractComponentType compType) { // will check current level if some of them are not null or sublevels if they exist bool[] nullability = compType.PropertyNullability; if (nullability != null) { //do the test object[] values = compType.GetPropertyValues(value, session.EntityMode); IType[] propertyTypes = compType.Subtypes; for (int i = 0; i < values.Length; i++) { object subvalue = values[i]; if (!nullability[i] && subvalue == null) { return compType.PropertyNames[i]; } else if (subvalue != null) { string breakProperties = CheckSubElementsNullability(propertyTypes[i], subvalue); if (breakProperties != null) { return BuildPropertyPath(compType.PropertyNames[i], breakProperties); } } } } return null; }
protected void InitComponentPropertyPaths(string path, IAbstractComponentType type, string[] columns, string[] formulaTemplates, IMapping factory) { IType[] types = type.Subtypes; string[] properties = type.PropertyNames; int begin = 0; for (int i = 0; i < properties.Length; i++) { string subpath = ExtendPath(path, properties[i]); try { int length = types[i].GetColumnSpan(factory); string[] columnSlice = ArrayHelper.Slice(columns, begin, length); string[] formulaSlice = formulaTemplates == null ? null : ArrayHelper.Slice(formulaTemplates, begin, length); InitPropertyPaths(subpath, types[i], columnSlice, formulaSlice, factory); begin += length; } catch (Exception e) { throw new MappingException("bug in InitComponentPropertyPaths", e); } } }
internal override async Task <object> ProcessComponentAsync(object component, IAbstractComponentType componentType, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); IType[] types = componentType.Subtypes; if (component == null) { await(ProcessValuesAsync(new object[types.Length], types, cancellationToken)).ConfigureAwait(false); } else { await(base.ProcessComponentAsync(component, componentType, cancellationToken)).ConfigureAwait(false); } return(null); }