private static void applyLength(Property property, ConstraintDescriptor<?> descriptor, PropertyDescriptor propertyDescriptor) { if ( "org.hibernate.validator.constraints.Length".equals( descriptor.getAnnotation().annotationType().getName() ) && String.class.equals( propertyDescriptor.getElementClass() ) ) { @SuppressWarnings("unchecked") int max = (Integer) descriptor.getAttributes().get( "max" ); @SuppressWarnings("unchecked") final Iterator<Selectable> itor = property.getColumnIterator(); if ( itor.hasNext() ) { final Selectable selectable = itor.next(); if ( Column.class.isInstance( selectable ) ) { Column col = (Column) selectable; if ( max < Integer.MAX_VALUE ) { col.setLength( max ); } } } } }
private static void applySize(Property property, ConstraintDescriptor<?> descriptor, PropertyDescriptor propertyDescriptor) { if ( Size.class.equals( descriptor.getAnnotation().annotationType() ) && String.class.equals( propertyDescriptor.getElementClass() ) ) { @SuppressWarnings("unchecked") ConstraintDescriptor<Size> sizeConstraint = (ConstraintDescriptor<Size>) descriptor; int max = sizeConstraint.getAnnotation().max(); @SuppressWarnings("unchecked") final Iterator<Selectable> itor = property.getColumnIterator(); if ( itor.hasNext() ) { final Selectable selectable = itor.next(); Column col = (Column) selectable; if ( max < Integer.MAX_VALUE ) { col.setLength( max ); } } } }
private void alignColumns(Table referencedTable) { final int referencedPkColumnSpan = referencedTable.getPrimaryKey().getColumnSpan(); if ( referencedPkColumnSpan != getColumnSpan() ) { StringBuilder sb = new StringBuilder(); sb.append( "Foreign key (" ).append( getName() ).append( ":" ) .append( getTable().getName() ) .append( " [" ); appendColumns( sb, getColumnIterator() ); sb.append( "])" ) .append( ") must have same number of columns as the referenced primary key (" ) .append( referencedTable.getName() ) .append( " [" ); appendColumns( sb, referencedTable.getPrimaryKey().getColumnIterator() ); sb.append( "])" ); throw new MappingException( sb.toString() ); } Iterator fkCols = getColumnIterator(); Iterator pkCols = referencedTable.getPrimaryKey().getColumnIterator(); while ( pkCols.hasNext() ) { ( (Column) fkCols.next() ).setLength( ( (Column) pkCols.next() ).getLength() ); } }
private void applyComponentColumnSizeValueToJoinColumn(Column column, Ejb3JoinColumn joinColumn) { Column mappingColumn = joinColumn.getMappingColumn(); mappingColumn.setLength( column.getLength() ); mappingColumn.setPrecision( column.getPrecision() ); mappingColumn.setScale( column.getScale() ); }
this.mappingColumn = new Column(); redefineColumnName( columnName, propertyName, applyNamingStrategy ); this.mappingColumn.setLength( length ); if ( precision > 0 ) { //revelent precision this.mappingColumn.setPrecision( precision );
/** * Called to apply column definitions from the referenced FK column to this column. * * @param column the referenced column. */ public void overrideFromReferencedColumnIfNecessary(org.hibernate.mapping.Column column) { if (getMappingColumn() != null) { // columnDefinition can also be specified using @JoinColumn, hence we have to check // whether it is set or not if ( StringHelper.isEmpty( sqlType ) ) { sqlType = column.getSqlType(); getMappingColumn().setSqlType( sqlType ); } // these properties can only be applied on the referenced column - we can just take them over getMappingColumn().setLength(column.getLength()); getMappingColumn().setPrecision(column.getPrecision()); getMappingColumn().setScale(column.getScale()); } }
/** * Shallow copy, the value is not copied */ @Override public Column clone() { Column copy = new Column(); copy.setLength( length ); copy.setScale( scale ); copy.setValue( value ); copy.setTypeIndex( typeIndex ); copy.setName( getQuotedName() ); copy.setNullable( nullable ); copy.setPrecision( precision ); copy.setUnique( unique ); copy.setSqlType( sqlType ); copy.setSqlTypeCode( sqlTypeCode ); copy.uniqueInteger = uniqueInteger; //usually useless copy.setCheckConstraint( checkConstraint ); copy.setComment( comment ); copy.setDefaultValue( defaultValue ); copy.setCustomRead( customRead ); copy.setCustomWrite( customWrite ); return copy; }
private static void applyLength(Property property, ConstraintDescriptor<?> descriptor, PropertyDescriptor propertyDescriptor) { if ( "org.hibernate.validator.constraints.Length".equals(descriptor.getAnnotation().annotationType().getName()) && String.class.equals( propertyDescriptor.getElementClass() ) ) { @SuppressWarnings("unchecked") int max = (Integer) descriptor.getAttributes().get( "max" ); Column col = ( Column ) property.getColumnIterator().next(); if ( max < Integer.MAX_VALUE ) { col.setLength( max ); } } }
Column column = (Column) mappedByColumns.next(); Column copy = new Column(); copy.setLength( column.getLength() ); copy.setScale( column.getScale() ); copy.setValue( key );
private static void applySize(Property property, ConstraintDescriptor<?> descriptor, PropertyDescriptor propertyDescriptor) { if ( Size.class.equals( descriptor.getAnnotation().annotationType() ) && String.class.equals( propertyDescriptor.getElementClass() ) ) { @SuppressWarnings("unchecked") ConstraintDescriptor<Size> sizeConstraint = ( ConstraintDescriptor<Size> ) descriptor; int max = sizeConstraint.getAnnotation().max(); Column col = ( Column ) property.getColumnIterator().next(); if ( max < Integer.MAX_VALUE ) { col.setLength( max ); } } }
Column column = (Column) otherSideJoinKeyColumns.next(); Column copy = new Column(); copy.setLength( column.getLength() ); copy.setScale( column.getScale() ); copy.setValue( manyToOne );
protected void initMappingColumn( String columnName, String propertyName, int length, int precision, int scale, boolean nullable, String sqlType, boolean unique, boolean applyNamingStrategy) { if ( StringHelper.isNotEmpty( formulaString ) ) { this.formula = new Formula(); this.formula.setFormula( formulaString ); } else { this.mappingColumn = new Column(); redefineColumnName( columnName, propertyName, applyNamingStrategy ); this.mappingColumn.setLength( length ); if ( precision > 0 ) { //revelent precision this.mappingColumn.setPrecision( precision ); this.mappingColumn.setScale( scale ); } this.mappingColumn.setNullable( nullable ); this.mappingColumn.setSqlType( sqlType ); this.mappingColumn.setUnique( unique ); } }
/** * Called to apply column definitions from the referenced FK column to this column. * * @param column the referenced column. */ public void overrideFromReferencedColumnIfNecessary(org.hibernate.mapping.Column column) { if (getMappingColumn() != null) { // columnDefinition can also be specified using @JoinColumn, hence we have to check // whether it is set or not if ( StringHelper.isEmpty( sqlType ) ) { sqlType = column.getSqlType(); getMappingColumn().setSqlType( sqlType ); } // these properties can only be applied on the referenced column - we can just take them over getMappingColumn().setLength(column.getLength()); getMappingColumn().setPrecision(column.getPrecision()); getMappingColumn().setScale(column.getScale()); } }
public void apply(Property property) { Column col = (Column) property.getColumnIterator().next(); if ( max < Integer.MAX_VALUE ) col.setLength( max ); }
Column column = (Column) mappedByColumns.next(); Column copy = new Column(); copy.setLength( column.getLength() ); copy.setScale( column.getScale() ); copy.setValue( key );
private static void applySize(Property property, ConstraintDescriptor<?> descriptor, PropertyDescriptor propertyDescriptor) { if ( Size.class.equals( descriptor.getAnnotation().annotationType() ) && String.class.equals( propertyDescriptor.getElementClass() ) ) { @SuppressWarnings("unchecked") ConstraintDescriptor<Size> sizeConstraint = (ConstraintDescriptor<Size>) descriptor; int max = sizeConstraint.getAnnotation().max(); Column col = (Column) property.getColumnIterator().next(); if ( max < Integer.MAX_VALUE ) { col.setLength( max ); } } }
private static void applySize(PersistentAttributeMapping property, ConstraintDescriptor<?> descriptor, PropertyDescriptor propertyDescriptor) { if ( Size.class.equals( descriptor.getAnnotation().annotationType() ) && String.class.equals( propertyDescriptor.getElementClass() ) ) { @SuppressWarnings("unchecked") final ConstraintDescriptor<Size> sizeConstraint = (ConstraintDescriptor<Size>) descriptor; final int max = sizeConstraint.getAnnotation().max(); final Column col = getColumn( property ); if ( max < Integer.MAX_VALUE ) { col.setLength( (long) max ); } } }
Column column = (Column) otherSideJoinKeyColumns.next(); Column copy = new Column(); copy.setLength( column.getLength() ); copy.setScale( column.getScale() ); copy.setValue( manyToOne );
private static void linkValueUsingAColumnCopy(GrailsDomainClassProperty prop, Column column, DependantValue key) { Column mappingColumn = new Column(); mappingColumn.setName(column.getName()); mappingColumn.setLength(column.getLength()); mappingColumn.setNullable(prop.isOptional()); mappingColumn.setSqlType(column.getSqlType()); mappingColumn.setValue(key); key.addColumn(mappingColumn); key.getTable().addColumn(mappingColumn); }