本文整理了Java中org.hibernate.mapping.Column.setNullable()
方法的一些代码示例,展示了Column.setNullable()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Column.setNullable()
方法的具体详情如下:
包路径:org.hibernate.mapping.Column
类名称:Column
方法名:setNullable
暂无
代码示例来源:origin: hibernate/hibernate-orm
public void setNullable(boolean nullable) {
if ( mappingColumn != null ) {
mappingColumn.setNullable( nullable );
}
else {
this.nullable = nullable;
}
}
代码示例来源:origin: hibernate/hibernate-orm
public void forceNotNull() {
if ( mappingColumn == null ) {
throw new CannotForceNonNullableException(
"Cannot perform #forceNotNull because internal org.hibernate.mapping.Column reference is null: " +
"likely a formula"
);
}
mappingColumn.setNullable( false );
}
代码示例来源:origin: hibernate/hibernate-orm
@SuppressWarnings("unchecked")
private static boolean applyNotNull(Property property, ConstraintDescriptor<?> descriptor) {
boolean hasNotNull = false;
if ( NotNull.class.equals( descriptor.getAnnotation().annotationType() ) ) {
// single table inheritance should not be forced to null due to shared state
if ( !( property.getPersistentClass() instanceof SingleTableSubclass ) ) {
//composite should not add not-null on all columns
if ( !property.isComposite() ) {
final Iterator<Selectable> itr = property.getColumnIterator();
while ( itr.hasNext() ) {
final Selectable selectable = itr.next();
if ( Column.class.isInstance( selectable ) ) {
Column.class.cast( selectable ).setNullable( false );
}
else {
LOG.debugf(
"@NotNull was applied to attribute [%s] which is defined (at least partially) " +
"by formula(s); formula portions will be skipped",
property.getName()
);
}
}
}
}
hasNotNull = true;
}
return hasNotNull;
}
代码示例来源:origin: hibernate/hibernate-orm
@Override
public void addColumn(Column column) {
final Iterator<Column> columnIterator = getTable().getColumnIterator();
while ( columnIterator.hasNext() ) {
final Column next = columnIterator.next();
if ( next.getCanonicalName().equals( column.getCanonicalName() ) ) {
next.setNullable( false );
log.debugf(
"Forcing column [%s] to be non-null as it is part of the primary key for table [%s]",
column.getCanonicalName(),
getTableNameForLogging( column )
);
}
}
super.addColumn( column );
}
代码示例来源:origin: hibernate/hibernate-orm
public void addColumn(Column column) {
Column old = getColumn( column );
if ( old == null ) {
if ( primaryKey != null ) {
for ( Column c : primaryKey.getColumns() ) {
if ( c.getCanonicalName().equals( column.getCanonicalName() ) ) {
column.setNullable( false );
log.debugf(
"Forcing column [%s] to be non-null as it is part of the primary key for table [%s]",
column.getCanonicalName(),
getNameIdentifier().getCanonicalName()
);
}
}
}
this.columns.put( column.getCanonicalName(), column );
column.uniqueInteger = this.columns.size();
}
else {
column.uniqueInteger = old.uniqueInteger;
}
}
代码示例来源:origin: hibernate/hibernate-orm
private void makeOneToManyMapKeyColumnNullableIfNotInProperty(
final XProperty property) {
final org.hibernate.mapping.Map map = (org.hibernate.mapping.Map) this.collection;
if ( map.isOneToMany() &&
property.isAnnotationPresent( MapKeyColumn.class ) ) {
final Value indexValue = map.getIndex();
if ( indexValue.getColumnSpan() != 1 ) {
throw new AssertionFailure( "Map key mapped by @MapKeyColumn does not have 1 column" );
}
final Selectable selectable = indexValue.getColumnIterator().next();
if ( selectable.isFormula() ) {
throw new AssertionFailure( "Map key mapped by @MapKeyColumn is a Formula" );
}
Column column = (Column) map.getIndex().getColumnIterator().next();
if ( !column.isNullable() ) {
final PersistentClass persistentClass = ( ( OneToMany ) map.getElement() ).getAssociatedClass();
// check if the index column has been mapped by the associated entity to a property;
// @MapKeyColumn only maps a column to the primary table for the one-to-many, so we only
// need to check "un-joined" properties.
if ( !propertyIteratorContainsColumn( persistentClass.getUnjoinedPropertyIterator(), column ) ) {
// The index column is not mapped to an associated entity property so we can
// safely make the index column nullable.
column.setNullable( true );
}
}
}
}
代码示例来源:origin: org.hibernate/hibernate-annotations
public void setNullable(boolean nullable) {
if ( mappingColumn != null ) {
mappingColumn.setNullable( nullable );
}
else {
this.nullable = nullable;
}
}
代码示例来源:origin: org.hibernate/hibernate-annotations
public void forceNotNull() {
mappingColumn.setNullable( false );
}
代码示例来源:origin: hibernate/hibernate-orm
this.mappingColumn.setScale( scale );
this.mappingColumn.setNullable( nullable );
this.mappingColumn.setSqlType( sqlType );
this.mappingColumn.setUnique( unique );
代码示例来源:origin: hibernate/hibernate-orm
/**
* 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;
}
代码示例来源:origin: hibernate/hibernate-orm
copy.setValue( key );
copy.setName( column.getQuotedName() );
copy.setNullable( column.isNullable() );
copy.setPrecision( column.getPrecision() );
copy.setUnique( column.isUnique() );
代码示例来源:origin: org.hibernate/hibernate-annotations
private static boolean applyNotNull(Property property, ConstraintDescriptor<?> descriptor) {
boolean hasNotNull = false;
if ( NotNull.class.equals( descriptor.getAnnotation().annotationType() ) ) {
if ( ! ( property.getPersistentClass() instanceof SingleTableSubclass ) ) {
//single table should not be forced to null
if ( !property.isComposite() ) { //composite should not add not-null on all columns
@SuppressWarnings( "unchecked" )
Iterator<Column> iter = (Iterator<Column>) property.getColumnIterator();
while ( iter.hasNext() ) {
iter.next().setNullable( false );
hasNotNull = true;
}
}
}
hasNotNull = true;
}
return hasNotNull;
}
代码示例来源:origin: hibernate/hibernate-orm
dialect.getTypeName( Types.VARCHAR, segmentValueLength, 0, 0 )
);
segmentColumn.setNullable( false );
table.addColumn( segmentColumn );
代码示例来源:origin: hibernate/hibernate-orm
database.getDialect().getTypeName( Types.VARCHAR, keySize, 0, 0 )
);
pkColumn.setNullable( false );
table.addColumn( pkColumn );
table.getPrimaryKey().addColumn( pkColumn );
代码示例来源:origin: hibernate/hibernate-orm
copy.setValue( manyToOne );
copy.setName( column.getQuotedName() );
copy.setNullable( column.isNullable() );
copy.setPrecision( column.getPrecision() );
copy.setUnique( column.isUnique() );
代码示例来源:origin: hibernate/hibernate-orm
column.setNullable( interpretNullability( columnSource.isNullable(), areColumnsNullableByDefault ) );
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate
public void setNullable(boolean nullable) {
if ( mappingColumn != null ) {
mappingColumn.setNullable( nullable );
}
else {
this.nullable = nullable;
}
}
代码示例来源:origin: org.hibernate/hibernate-annotations
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 );
}
}
代码示例来源:origin: org.hibernate/hibernate-annotations
copy.setValue( key );
copy.setName( column.getQuotedName() );
copy.setNullable( column.isNullable() );
copy.setPrecision( column.getPrecision() );
copy.setUnique( column.isUnique() );
代码示例来源:origin: org.hibernate/hibernate-annotations
copy.setValue( manyToOne );
copy.setName( column.getQuotedName() );
copy.setNullable( column.isNullable() );
copy.setPrecision( column.getPrecision() );
copy.setUnique( column.isUnique() );
内容来源于网络,如有侵权,请联系作者删除!