Ejemplo n.º 1
0
        private static Ejb3Column[] BuildImplicitColumn(IPropertyData inferredData,
                                                        IDictionary <string, Join> secondaryTables,
                                                        IPropertyHolder propertyHolder, Nullability nullability,
                                                        ExtendedMappings mappings)
        {
            Ejb3Column[] columns;
            columns = new Ejb3Column[1];
            Ejb3Column column = new Ejb3Column();

            column.SetImplicit(false);
            //not following the spec but more clean
            if (nullability != Nullability.ForcedNull && inferredData.ClassOrElement.IsPrimitive &&
                !inferredData.Property.GetType().IsArray)         //TODO: IsArray in this way ???
            {
                column.SetNullable(false);
            }
            column.SetLength(DEFAULT_COLUMN_LENGTH);
            column.PropertyName   = BinderHelper.GetRelativePath(propertyHolder, inferredData.PropertyName);
            column.PropertyHolder = propertyHolder;
            column.SetJoins(secondaryTables);
            column.Mappings = mappings;
            column.Bind();
            columns[0] = column;
            return(columns);
        }
Ejemplo n.º 2
0
		public void SetColumns(Ejb3Column[] columns)
		{
			insertable = columns[0].IsInsertable;
			updatable = columns[0].IsUpdatable;
			//consistency is checked later when we know the proeprty name
			this.columns = columns;
		}
Ejemplo n.º 3
0
        public static Ejb3Column[] BuildColumnFromAnnotation(
            ColumnAttribute[] anns,
            FormulaAttribute formulaAnn, Nullability nullability, IPropertyHolder propertyHolder,
            IPropertyData inferredData,
            IDictionary <string, Join> secondaryTables,
            ExtendedMappings mappings)
        {
            Ejb3Column[] columns;

            if (formulaAnn != null)
            {
                Ejb3Column formulaColumn = new Ejb3Column();
                formulaColumn.SetFormula(formulaAnn.Value);
                formulaColumn.SetImplicit(false);
                formulaColumn.Mappings       = mappings;
                formulaColumn.PropertyHolder = propertyHolder;
                formulaColumn.Bind();
                columns = new Ejb3Column[] { formulaColumn };
            }
            else
            {
                columns = BuildColumnFromAnnotation(anns,
                                                    nullability,
                                                    propertyHolder,
                                                    inferredData,
                                                    secondaryTables,
                                                    mappings);
            }
            return(columns);
        }
Ejemplo n.º 4
0
 public IndexOrUniqueKeySecondPass(string indexName, Ejb3Column column, ExtendedMappings mappings, bool unique)
 {
     this.indexName = indexName;
     this.column    = column;
     columns        = null;
     this.mappings  = mappings;
     this.unique    = unique;
 }
		public IndexOrUniqueKeySecondPass(string indexName, Ejb3Column column, ExtendedMappings mappings, bool unique)
		{
			this.indexName = indexName;
			this.column = column;
			columns = null;
			this.mappings = mappings;
			this.unique = unique;
		}
Ejemplo n.º 6
0
 public IndexOrUniqueKeySecondPass(Table table, string indexName, string[] columns, ExtendedMappings mappings)
 {
     this.table     = table;
     this.indexName = indexName;
     this.columns   = columns;
     this.mappings  = mappings;
     column         = null;
     unique         = false;
 }
		public IndexOrUniqueKeySecondPass(Table table, string indexName, string[] columns, ExtendedMappings mappings)
		{
			this.table = table;
			this.indexName = indexName;
			this.columns = columns;
			this.mappings = mappings;
			column = null;
			unique = false;
		}
Ejemplo n.º 8
0
        private static Ejb3Column[] BuildColumnFromAnnotation(ColumnAttribute[] anns, Nullability nullability,
                                                              IPropertyHolder propertyHolder, IPropertyData inferredData,
                                                              IDictionary <string, Join> secondaryTables,
                                                              ExtendedMappings mappings)
        {
            ColumnAttribute[] actualCols     = anns;
            ColumnAttribute[] overriddenCols = propertyHolder.GetOverriddenColumn(StringHelper.Qualify(propertyHolder.Path, inferredData.PropertyName));

            if (overriddenCols != null)
            {
                //check for overridden first
                if (anns != null && overriddenCols.Length != anns.Length)
                {
                    throw new AnnotationException("AttributeOverride.column() should override all columns for now");
                }

                actualCols = overriddenCols.Length == 0 ? null : overriddenCols;
                log.DebugFormat("Column(s) overridden for property {0}", inferredData.PropertyName);
            }

            if (actualCols == null)
            {
                return(BuildImplicitColumn(inferredData, secondaryTables, propertyHolder, nullability, mappings));
            }

            int length = actualCols.Length;

            Ejb3Column[] columns = new Ejb3Column[length];
            for (int index = 0; index < length; index++)
            {
                ColumnAttribute col     = actualCols[index];
                String          sqlType = col.ColumnDefinition.Equals("") ? null : col.ColumnDefinition;
                Ejb3Column      column  = new Ejb3Column();
                column.SetImplicit(false);
                column.SetSqlType(sqlType);
                column.SetLength(col.Length);
                column.SetPrecision(col.Precision);
                column.SetScale(col.Scale);
                column.SetLogicalColumnName(col.Name);
                column.PropertyName = BinderHelper.GetRelativePath(propertyHolder, inferredData.PropertyName);
                column.SetNullable(col.Nullable); //TODO force to not null if available? This is a (bad) user choice.
                column.SetUnique(col.Unique);
                column.SetInsertable(col.Insertable);
                column.SetUpdatable(col.Updatable);
                column.SetSecondaryTableName(col.Table);
                column.PropertyHolder = propertyHolder;
                column.SetJoins(secondaryTables);
                column.Mappings = mappings;
                column.Bind();
                columns[index] = column;
            }
            return(columns);
        }
 public void AddProperty(Property prop, Ejb3Column[] columns)
 {
     //Ejb3Column.checkPropertyConsistency( ); //already called earlier
     if (columns[0].IsSecondary)
     {
         //TODO move the getJoin() code here?
         columns[0].Join.AddProperty(prop);
     }
     else
     {
         AddProperty(prop);
     }
 }
		public void SetColumns(Ejb3Column[] columns)
		{
			this.columns = columns;
		}
Ejemplo n.º 11
0
 public static void checkPropertyConsistency(Ejb3Column[] columns, String propertyName)
 {
     int nbrOfColumns = columns.Length;
     if (nbrOfColumns > 1)
     {
         for (int currentIndex = 1; currentIndex < nbrOfColumns; currentIndex++)
         {
             if (columns[currentIndex].IsInsertable != columns[currentIndex - 1].IsInsertable)
             {
                 throw new AnnotationException("Mixing insertable and non insertable columns in a property is not allowed: " + propertyName);
             }
             if (columns[currentIndex].IsNullable != columns[currentIndex - 1].IsNullable)
             {
                 throw new AnnotationException("Mixing nullable and non nullable columns in a property is not allowed: " + propertyName);
             }
             if (columns[currentIndex].IsUpdatable != columns[currentIndex - 1].IsUpdatable)
             {
                 throw new AnnotationException("Mixing updatable and non updatable columns in a property is not allowed: " + propertyName);
             }
             if (!columns[currentIndex].Table.Equals(columns[currentIndex - 1].Table))
             {
                 throw new AnnotationException("Mixing different tables in a property is not allowed: " + propertyName);
             }
         }
     }
 }
Ejemplo n.º 12
0
 private static Ejb3Column[] BuildImplicitColumn(IPropertyData inferredData,
                                                 IDictionary<string, Join> secondaryTables,
                                                 IPropertyHolder propertyHolder, Nullability nullability,
                                                 ExtendedMappings mappings)
 {
     Ejb3Column[] columns;
     columns = new Ejb3Column[1];
     Ejb3Column column = new Ejb3Column();
     column.SetImplicit(false);
     //not following the spec but more clean
     if (nullability != Nullability.ForcedNull  && inferredData.ClassOrElement.IsPrimitive
             && !inferredData.Property.GetType().IsArray ) //TODO: IsArray in this way ???
     {
         column.SetNullable(false);
     }
     column.SetLength(DEFAULT_COLUMN_LENGTH);
     column.PropertyName = BinderHelper.GetRelativePath(propertyHolder, inferredData.PropertyName);
     column.PropertyHolder = propertyHolder;
     column.SetJoins(secondaryTables);
     column.Mappings = mappings;
     column.Bind();
     columns[0] = column;
     return columns;
 }
Ejemplo n.º 13
0
        private static Ejb3Column[] BuildColumnFromAnnotation(ColumnAttribute[] anns, Nullability nullability,
                                                              IPropertyHolder propertyHolder, IPropertyData inferredData,
                                                              IDictionary<string, Join> secondaryTables,
                                                              ExtendedMappings mappings)
        {
            ColumnAttribute[] actualCols = anns;
            ColumnAttribute[] overriddenCols = propertyHolder.GetOverriddenColumn(StringHelper.Qualify(propertyHolder.Path, inferredData.PropertyName));

            if (overriddenCols != null)
            {
                //check for overridden first
                if (anns != null && overriddenCols.Length != anns.Length)
                    throw new AnnotationException("AttributeOverride.column() should override all columns for now");

                actualCols = overriddenCols.Length == 0 ? null : overriddenCols;
                log.DebugFormat("Column(s) overridden for property {0}", inferredData.PropertyName);
            }

            if (actualCols == null)
                return BuildImplicitColumn(inferredData, secondaryTables, propertyHolder, nullability, mappings);

            int length = actualCols.Length;
            Ejb3Column[] columns = new Ejb3Column[length];
            for (int index = 0; index < length; index++)
            {
                ColumnAttribute col = actualCols[index];
                String sqlType = col.ColumnDefinition.Equals("") ? null : col.ColumnDefinition;
                Ejb3Column column = new Ejb3Column();
                column.SetImplicit(false);
                column.SetSqlType(sqlType);
                column.SetLength(col.Length);
                column.SetPrecision(col.Precision);
                column.SetScale(col.Scale);
                column.SetLogicalColumnName(col.Name);
                column.PropertyName = BinderHelper.GetRelativePath(propertyHolder, inferredData.PropertyName);
                column.SetNullable(col.Nullable); //TODO force to not null if available? This is a (bad) user choice.
                column.SetUnique(col.Unique);
                column.SetInsertable(col.Insertable);
                column.SetUpdatable(col.Updatable);
                column.SetSecondaryTableName(col.Table);
                column.PropertyHolder = propertyHolder;
                column.SetJoins(secondaryTables);
                column.Mappings = mappings;
                column.Bind();
                columns[index] = column;
            }
            return columns;
        }
Ejemplo n.º 14
0
        public static Ejb3Column[] BuildColumnFromAnnotation(
            ColumnAttribute[] anns,
            FormulaAttribute formulaAnn, Nullability nullability, IPropertyHolder propertyHolder,
            IPropertyData inferredData,
            IDictionary<string, Join> secondaryTables,
            ExtendedMappings mappings)
        {
            Ejb3Column[] columns;

            if (formulaAnn != null)
            {
                Ejb3Column formulaColumn = new Ejb3Column();
                formulaColumn.SetFormula(formulaAnn.Value);
                formulaColumn.SetImplicit(false);
                formulaColumn.Mappings = mappings;
                formulaColumn.PropertyHolder = propertyHolder;
                formulaColumn.Bind();
                columns = new Ejb3Column[] {formulaColumn};
            }
            else
            {
                columns = BuildColumnFromAnnotation(anns,
                                                    nullability,
                                                    propertyHolder,
                                                    inferredData,
                                                    secondaryTables,
                                                    mappings);
            }
            return columns;
        }
Ejemplo n.º 15
0
 public IndexOrUniqueKeySecondPass(string indexName, Ejb3Column column, ExtendedMappings mappings)
     : this(indexName, column, mappings, false)
 {
 }
		public IndexOrUniqueKeySecondPass(string indexName, Ejb3Column column, ExtendedMappings mappings)
			: this(indexName, column, mappings, false)
		{
		}
		public void AddProperty(Property prop, Ejb3Column[] columns)
		{
			throw new System.NotImplementedException();
		}