Example #1
0
        /// <summary>
        /// Pendent
        /// </summary>
        public Configuration[] GetAllConfigurations()
        {
            HashedSet set = new HashedSet(type2Conf.Values);

            Configuration[] confs = new Configuration[set.Count];

            set.CopyTo(confs, 0);

            return(confs);
        }
		/// <summary>
		/// Pendent
		/// </summary>
		public Configuration[] GetAllConfigurations()
		{
			HashedSet set = new HashedSet(type2Conf.Values);

			Configuration[] confs = new Configuration[set.Count];

			set.CopyTo(confs, 0);

			return confs;
		}
Example #3
0
        /// <summary>
        /// Sets error message that should be displayed in the case
        /// of a non-fatal binding error.
        /// </summary>
        /// <param name="messageId">
        /// Resource ID of the error message.
        /// </param>
        /// <param name="errorProviders">
        /// List of error providers message should be added to.
        /// </param>
        public void SetErrorMessage(string messageId, params string[] errorProviders)
        {
            AssertUtils.ArgumentHasText(messageId, "messageId");
            if (errorProviders == null || errorProviders.Length == 0)
            {
                throw new ArgumentException("At least one error provider has to be specified.", "providers");
            }

            this.errorMessage = new BindingErrorMessage(this.BINDING_ID, messageId, null);
            Set providers = new HashedSet();

            providers.Add(ALL_BINDINGERRORS_PROVIDER);
            providers.AddAll(errorProviders);
            errorProviders = new string[providers.Count];
            providers.CopyTo(errorProviders, 0);
            this.errorProviders = errorProviders;
        }
        /// <summary>
        /// Sets error message that should be displayed in the case 
        /// of a non-fatal binding error.
        /// </summary>
        /// <param name="messageId">
        /// Resource ID of the error message.
        /// </param>
        /// <param name="errorProviders">
        /// List of error providers message should be added to.
        /// </param>
        public void SetErrorMessage(string messageId, params string[] errorProviders)
        {
            AssertUtils.ArgumentHasText(messageId, "messageId");
            if (errorProviders == null || errorProviders.Length == 0)
            {
                throw new ArgumentException("At least one error provider has to be specified.", "providers");
            }

            this.errorMessage = new BindingErrorMessage(this.BINDING_ID, messageId, null);
            Set providers = new HashedSet();
            providers.Add(ALL_BINDINGERRORS_PROVIDER);
            providers.AddAll(errorProviders);
            errorProviders = new string[providers.Count];
            providers.CopyTo(errorProviders, 0);
            this.errorProviders = errorProviders;
        }
		public UnionSubclassEntityPersister(PersistentClass persistentClass, ICacheConcurrencyStrategy cache, 
			ISessionFactoryImplementor factory, IMapping mapping):base(persistentClass, cache, factory)
		{
			if (IdentifierGenerator is IdentityGenerator)
			{
				throw new MappingException("Cannot use identity column key generation with <union-subclass> mapping for: " + EntityName);
			}

			// TABLE

			tableName =
				persistentClass.Table.GetQualifiedName(factory.Dialect, factory.Settings.DefaultCatalogName,
				                                       factory.Settings.DefaultSchemaName);

			#region Custom SQL

			SqlString sql;
			bool callable;
			ExecuteUpdateResultCheckStyle checkStyle;

			sql = persistentClass.CustomSQLInsert;
			callable = sql != null && persistentClass.IsCustomInsertCallable;
			checkStyle = sql == null
			             	? ExecuteUpdateResultCheckStyle.Count
			             	: (persistentClass.CustomSQLInsertCheckStyle
			             	   ?? ExecuteUpdateResultCheckStyle.DetermineDefault(sql, callable));
			customSQLInsert = new SqlString[] { sql };
			insertCallable = new bool[] { callable };
			insertResultCheckStyles = new ExecuteUpdateResultCheckStyle[] { checkStyle };

			sql = persistentClass.CustomSQLUpdate;
			callable = sql != null && persistentClass.IsCustomUpdateCallable;
			checkStyle = sql == null
			             	? ExecuteUpdateResultCheckStyle.Count
			             	: (persistentClass.CustomSQLUpdateCheckStyle
			             	   ?? ExecuteUpdateResultCheckStyle.DetermineDefault(sql, callable));
			customSQLUpdate = new SqlString[] { sql };
			updateCallable = new bool[] { callable };
			updateResultCheckStyles = new ExecuteUpdateResultCheckStyle[] { checkStyle };

			sql = persistentClass.CustomSQLDelete;
			callable = sql != null && persistentClass.IsCustomDeleteCallable;
			checkStyle = sql == null
			             	? ExecuteUpdateResultCheckStyle.Count
			             	: (persistentClass.CustomSQLDeleteCheckStyle
			             	   ?? ExecuteUpdateResultCheckStyle.DetermineDefault(sql, callable));
			customSQLDelete = new SqlString[] { sql };
			deleteCallable = new bool[] { callable };
			deleteResultCheckStyles = new ExecuteUpdateResultCheckStyle[] { checkStyle };

			#endregion

			discriminatorValue = persistentClass.SubclassId;
			discriminatorSQLValue = persistentClass.SubclassId.ToString();

			#region PROPERTIES

			int subclassSpan = persistentClass.SubclassSpan + 1;
			subclassClosure = new string[subclassSpan];
			subclassClosure[0] = EntityName;

			#endregion

			#region SUBCLASSES

			subclassByDiscriminatorValue[persistentClass.SubclassId] = persistentClass.EntityName;
			if (persistentClass.IsPolymorphic)
			{
				int k = 1;
				foreach (Subclass sc in persistentClass.SubclassIterator)
				{
					subclassClosure[k++] = sc.EntityName;
					subclassByDiscriminatorValue[sc.SubclassId] = sc.EntityName;
				}
			}

			#endregion

			#region SPACES
			//TODO: i'm not sure, but perhaps we should exclude abstract denormalized tables?

			int spacesSize = 1 + persistentClass.SynchronizedTables.Count;
			spaces = new string[spacesSize];
			spaces[0] = tableName;
			IEnumerator<string> iSyncTab = persistentClass.SynchronizedTables.GetEnumerator();
			for (int i = 1; i < spacesSize; i++)
			{
				iSyncTab.MoveNext();
				spaces[i] = iSyncTab.Current;
			}

			HashedSet<string> subclassTables = new HashedSet<string>();
			foreach (Table table in persistentClass.SubclassTableClosureIterator)
			{
				subclassTables.Add(
					table.GetQualifiedName(factory.Dialect, factory.Settings.DefaultCatalogName, factory.Settings.DefaultSchemaName));
			}
			subclassSpaces = new string[subclassTables.Count];
			subclassTables.CopyTo(subclassSpaces, 0);

			subquery = GenerateSubquery(persistentClass, mapping);

			if (IsMultiTable)
			{
				int idColumnSpan = IdentifierColumnSpan;
				List<string> tableNames = new List<string>();
				List<string[]> keyColumns = new List<string[]>();
				if (!IsAbstract)
				{
					tableNames.Add(tableName);
					keyColumns.Add(IdentifierColumnNames);
				}
				foreach (Table tab in persistentClass.SubclassTableClosureIterator)
				{
					if (!tab.IsAbstractUnionTable)
					{
						string _tableName =
							tab.GetQualifiedName(factory.Dialect, factory.Settings.DefaultCatalogName, factory.Settings.DefaultSchemaName);
						tableNames.Add(_tableName);

						List<string> key = new List<string>(idColumnSpan);
						foreach (Column column in tab.PrimaryKey.ColumnIterator)
							key.Add(column.GetQuotedName(factory.Dialect));

						keyColumns.Add(key.ToArray());
					}					
				}

				constraintOrderedTableNames = tableNames.ToArray();
				constraintOrderedKeyColumnNames = keyColumns.ToArray();
			}
			else
			{
				constraintOrderedTableNames = new string[] { tableName };
				constraintOrderedKeyColumnNames = new string[][] { IdentifierColumnNames };
			}
			#endregion

			InitLockers();

			InitSubclassPropertyAliasesMap(persistentClass);

			PostConstruct(mapping);
		}
Example #6
0
        public UnionSubclassEntityPersister(PersistentClass persistentClass, ICacheConcurrencyStrategy cache,
                                            ISessionFactoryImplementor factory, IMapping mapping) : base(persistentClass, cache, factory)
        {
            if (IdentifierGenerator is IdentityGenerator)
            {
                throw new MappingException("Cannot use identity column key generation with <union-subclass> mapping for: " + EntityName);
            }

            // TABLE

            tableName =
                persistentClass.Table.GetQualifiedName(factory.Dialect, factory.Settings.DefaultCatalogName,
                                                       factory.Settings.DefaultSchemaName);

            #region Custom SQL

            SqlString sql;
            bool      callable;
            ExecuteUpdateResultCheckStyle checkStyle;

            sql        = persistentClass.CustomSQLInsert;
            callable   = sql != null && persistentClass.IsCustomInsertCallable;
            checkStyle = sql == null
                                        ? ExecuteUpdateResultCheckStyle.Count
                                        : (persistentClass.CustomSQLInsertCheckStyle
                                           ?? ExecuteUpdateResultCheckStyle.DetermineDefault(sql, callable));
            customSQLInsert         = new SqlString[] { sql };
            insertCallable          = new bool[] { callable };
            insertResultCheckStyles = new ExecuteUpdateResultCheckStyle[] { checkStyle };

            sql        = persistentClass.CustomSQLUpdate;
            callable   = sql != null && persistentClass.IsCustomUpdateCallable;
            checkStyle = sql == null
                                        ? ExecuteUpdateResultCheckStyle.Count
                                        : (persistentClass.CustomSQLUpdateCheckStyle
                                           ?? ExecuteUpdateResultCheckStyle.DetermineDefault(sql, callable));
            customSQLUpdate         = new SqlString[] { sql };
            updateCallable          = new bool[] { callable };
            updateResultCheckStyles = new ExecuteUpdateResultCheckStyle[] { checkStyle };

            sql        = persistentClass.CustomSQLDelete;
            callable   = sql != null && persistentClass.IsCustomDeleteCallable;
            checkStyle = sql == null
                                        ? ExecuteUpdateResultCheckStyle.Count
                                        : (persistentClass.CustomSQLDeleteCheckStyle
                                           ?? ExecuteUpdateResultCheckStyle.DetermineDefault(sql, callable));
            customSQLDelete         = new SqlString[] { sql };
            deleteCallable          = new bool[] { callable };
            deleteResultCheckStyles = new ExecuteUpdateResultCheckStyle[] { checkStyle };

            #endregion

            discriminatorValue    = persistentClass.SubclassId;
            discriminatorSQLValue = persistentClass.SubclassId.ToString();

            #region PROPERTIES

            int subclassSpan = persistentClass.SubclassSpan + 1;
            subclassClosure    = new string[subclassSpan];
            subclassClosure[0] = EntityName;

            #endregion

            #region SUBCLASSES

            subclassByDiscriminatorValue[persistentClass.SubclassId] = persistentClass.EntityName;
            if (persistentClass.IsPolymorphic)
            {
                int k = 1;
                foreach (Subclass sc in persistentClass.SubclassIterator)
                {
                    subclassClosure[k++] = sc.EntityName;
                    subclassByDiscriminatorValue[sc.SubclassId] = sc.EntityName;
                }
            }

            #endregion

            #region SPACES
            //TODO: i'm not sure, but perhaps we should exclude abstract denormalized tables?

            int spacesSize = 1 + persistentClass.SynchronizedTables.Count;
            spaces    = new string[spacesSize];
            spaces[0] = tableName;
            IEnumerator <string> iSyncTab = persistentClass.SynchronizedTables.GetEnumerator();
            for (int i = 1; i < spacesSize; i++)
            {
                iSyncTab.MoveNext();
                spaces[i] = iSyncTab.Current;
            }

            HashedSet <string> subclassTables = new HashedSet <string>();
            foreach (Table table in persistentClass.SubclassTableClosureIterator)
            {
                subclassTables.Add(
                    table.GetQualifiedName(factory.Dialect, factory.Settings.DefaultCatalogName, factory.Settings.DefaultSchemaName));
            }
            subclassSpaces = new string[subclassTables.Count];
            subclassTables.CopyTo(subclassSpaces, 0);

            subquery = GenerateSubquery(persistentClass, mapping);

            if (IsMultiTable)
            {
                int             idColumnSpan = IdentifierColumnSpan;
                List <string>   tableNames   = new List <string>();
                List <string[]> keyColumns   = new List <string[]>();
                if (!IsAbstract)
                {
                    tableNames.Add(tableName);
                    keyColumns.Add(IdentifierColumnNames);
                }
                foreach (Table tab in persistentClass.SubclassTableClosureIterator)
                {
                    if (!tab.IsAbstractUnionTable)
                    {
                        string _tableName =
                            tab.GetQualifiedName(factory.Dialect, factory.Settings.DefaultCatalogName, factory.Settings.DefaultSchemaName);
                        tableNames.Add(_tableName);

                        List <string> key = new List <string>(idColumnSpan);
                        foreach (Column column in tab.PrimaryKey.ColumnIterator)
                        {
                            key.Add(column.GetQuotedName(factory.Dialect));
                        }

                        keyColumns.Add(key.ToArray());
                    }
                }

                constraintOrderedTableNames     = tableNames.ToArray();
                constraintOrderedKeyColumnNames = keyColumns.ToArray();
            }
            else
            {
                constraintOrderedTableNames     = new string[] { tableName };
                constraintOrderedKeyColumnNames = new string[][] { IdentifierColumnNames };
            }
            #endregion

            InitLockers();

            InitSubclassPropertyAliasesMap(persistentClass);

            PostConstruct(mapping);
        }