private static void applySQLCheck(Column col, String checkConstraint) { String existingCheck = col.getCheckConstraint(); // need to check whether the new check is already part of the existing check, because applyDDL can be called // multiple times if ( StringHelper.isNotEmpty( existingCheck ) && !existingCheck.contains( checkConstraint ) ) { checkConstraint = col.getCheckConstraint() + " AND " + checkConstraint; } col.setCheckConstraint( checkConstraint ); }
/** * 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; }
copy.setUnique( column.isUnique() ); copy.setSqlType( column.getSqlType() ); copy.setCheckConstraint( column.getCheckConstraint() ); copy.setComment( column.getComment() ); copy.setDefaultValue( column.getDefaultValue() );
private static void applyMin(Property property, ConstraintDescriptor<?> descriptor) { if ( Min.class.equals( descriptor.getAnnotation().annotationType() ) ) { @SuppressWarnings( "unchecked" ) ConstraintDescriptor<Min> minConstraint = (ConstraintDescriptor<Min>) descriptor; long min = minConstraint.getAnnotation().value(); Column col = (Column) property.getColumnIterator().next(); col.setCheckConstraint( col.getName() + ">=" + min ); } }
private static void applyMax(Property property, ConstraintDescriptor<?> descriptor) { if ( Max.class.equals( descriptor.getAnnotation().annotationType() ) ) { @SuppressWarnings( "unchecked" ) ConstraintDescriptor<Max> maxConstraint = (ConstraintDescriptor<Max>) descriptor; long max = maxConstraint.getAnnotation().value(); Column col = (Column) property.getColumnIterator().next(); col.setCheckConstraint( col.getName() + "<=" + max ); } }
copy.setUnique( column.isUnique() ); copy.setSqlType( column.getSqlType() ); copy.setCheckConstraint( column.getCheckConstraint() ); copy.setComment( column.getComment() ); copy.setDefaultValue( column.getDefaultValue() );
column.setCheckConstraint( columnSource.getCheckCondition() ); column.setDefaultValue( columnSource.getDefaultValue() ); column.setSqlType( columnSource.getSqlType() );
public void apply(Property property) { Column col = (Column) property.getColumnIterator().next(); col.setCheckConstraint( col.getName() + "<=" + max ); } }
public void apply(Property property) { Column col = (Column) property.getColumnIterator().next(); col.setCheckConstraint( col.getName() + "<=" + max ); } }
public void apply(Property property) { Column col = (Column) property.getColumnIterator().next(); col.setCheckConstraint( col.getName() + ">=" + min ); } }
public void apply(Property property) { Column col = (Column) property.getColumnIterator().next(); col.setCheckConstraint( col.getName() + " < current_date" ); } }
public void apply(Property property) { Column col = (Column) property.getColumnIterator().next(); col.setCheckConstraint( col.getName() + ">=" + min ); } }
private static void applySQLCheck(Column col, String checkConstraint) { String existingCheck = col.getCheckConstraint(); // need to check whether the new check is already part of the existing check, because applyDDL can be called // multiple times if ( StringHelper.isNotEmpty( existingCheck ) && !existingCheck.contains( checkConstraint ) ) { checkConstraint = col.getCheckConstraint() + " AND " + checkConstraint; } col.setCheckConstraint( checkConstraint ); }
copy.setUnique( column.isUnique() ); copy.setSqlType( column.getSqlType() ); copy.setCheckConstraint( column.getCheckConstraint() ); copy.setComment( column.getComment() ); copy.setDefaultValue( column.getDefaultValue() );
public void apply(Property property) { Column col = (Column) property.getColumnIterator().next(); String check = ""; if ( min != Long.MIN_VALUE ) check += col.getName() + ">=" + min; if ( max != Long.MAX_VALUE && min != Long.MIN_VALUE ) check += " and "; if ( max != Long.MAX_VALUE ) check += col.getName() + "<=" + max; col.setCheckConstraint( check ); }
private static void applySQLCheck(Column col, String checkConstraint) { String existingCheck = col.getCheckConstraint(); // need to check whether the new check is already part of the existing check, because applyDDL can be called // multiple times if ( StringHelper.isNotEmpty( existingCheck ) && !existingCheck.contains( checkConstraint ) ) { checkConstraint = col.getCheckConstraint() + " AND " + checkConstraint; } col.setCheckConstraint( checkConstraint ); }
public void apply(Property property) { Column col = (Column) property.getColumnIterator().next(); String check = ""; if ( min != Long.MIN_VALUE ) check += col.getName() + ">=" + min; if ( max != Long.MAX_VALUE && min != Long.MIN_VALUE ) check += " and "; if ( max != Long.MAX_VALUE ) check += col.getName() + "<=" + max; col.setCheckConstraint( check ); }
private static void applySQLCheck(Column col, String checkConstraint) { final String existingCheck = col.getCheckConstraint(); // need to check whether the new check is already part of the existing check, because applyDDL can be called // multiple times if ( StringHelper.isNotEmpty( existingCheck ) && !existingCheck.contains( checkConstraint ) ) { checkConstraint = col.getCheckConstraint() + " AND " + checkConstraint; } col.setCheckConstraint( checkConstraint ); }
copy.setUnique( column.isUnique() ); copy.setSqlType( column.getSqlType() ); copy.setCheckConstraint( column.getCheckConstraint() ); copy.setComment( column.getComment() ); copy.setDefaultValue( column.getDefaultValue() );
public static void bindColumn(Element node, Column column, boolean isNullable) { Attribute lengthNode = node.attribute( "length" ); if ( lengthNode != null ) column.setLength( Integer.parseInt( lengthNode.getValue() ) ); Attribute scalNode = node.attribute( "scale" ); if ( scalNode != null ) column.setScale( Integer.parseInt( scalNode.getValue() ) ); Attribute precNode = node.attribute( "precision" ); if ( precNode != null ) column.setPrecision( Integer.parseInt( precNode.getValue() ) ); Attribute nullNode = node.attribute( "not-null" ); column.setNullable( nullNode == null ? isNullable : nullNode.getValue().equals( "false" ) ); Attribute unqNode = node.attribute( "unique" ); if ( unqNode != null ) column.setUnique( unqNode.getValue().equals( "true" ) ); column.setCheckConstraint( node.attributeValue( "check" ) ); Attribute typeNode = node.attribute( "sql-type" ); if ( typeNode != null ) column.setSqlType( typeNode.getValue() ); Element comment = node.element("comment"); if (comment!=null) column.setComment( comment.getTextTrim() ); }