当前位置: 首页>>代码示例>>Java>>正文


Java Column.setScale方法代码示例

本文整理汇总了Java中org.hibernate.mapping.Column.setScale方法的典型用法代码示例。如果您正苦于以下问题:Java Column.setScale方法的具体用法?Java Column.setScale怎么用?Java Column.setScale使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.hibernate.mapping.Column的用法示例。


在下文中一共展示了Column.setScale方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: bindColumn

import org.hibernate.mapping.Column; //导入方法依赖的package包/类
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" ) );
	column.setDefaultValue( node.attributeValue( "default" ) );

	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() );

}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:25,代码来源:HbmBinder.java

示例2: normalizeColumns

import org.hibernate.mapping.Column; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
private void normalizeColumns(Table table, String entityName) {

	Iterator iterator = table.getColumnIterator();
	while (iterator.hasNext()) {

		Column column = (Column) iterator.next();

		String name = strategy.columnName(column.getName());
		String sqlType = strategy.sqlType(table.getName(), column.getSqlType());
		int sqlPrecision = strategy.sqlPrecision(table.getName(), column.getSqlType(), column.getPrecision());
		int sqlScale = strategy.sqlScale(table.getName(), column.getSqlType(), column.getScale());

		column.setName(name);
		column.setSqlType(sqlType);
		column.setPrecision(sqlPrecision);
		column.setScale(sqlScale);

	}

}
 
开发者ID:andreluiznsilva,项目名称:hibernate-conventions,代码行数:22,代码来源:MappingConventions.java

示例3: bindColumn

import org.hibernate.mapping.Column; //导入方法依赖的package包/类
public static void bindColumn(Element node, Column column, boolean isNullable) throws MappingException {
	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" ) );
	column.setDefaultValue( node.attributeValue( "default" ) );

	Attribute typeNode = node.attribute( "sql-type" );
	if ( typeNode != null ) column.setSqlType( typeNode.getValue() );

	String customWrite = node.attributeValue( "write" );
	if(customWrite != null && !customWrite.matches("[^?]*\\?[^?]*")) {
		throw new MappingException("write expression must contain exactly one value placeholder ('?') character");
	}
	column.setCustomWrite( customWrite );
	column.setCustomRead( node.attributeValue( "read" ) );

	Element comment = node.element("comment");
	if (comment!=null) column.setComment( comment.getTextTrim() );

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:32,代码来源:HbmBinder.java

示例4: applyDigits

import org.hibernate.mapping.Column; //导入方法依赖的package包/类
private static void applyDigits(Property property, ConstraintDescriptor<?> descriptor) {
	if ( Digits.class.equals( descriptor.getAnnotation().annotationType() ) ) {
		@SuppressWarnings("unchecked")
		ConstraintDescriptor<Digits> digitsConstraint = (ConstraintDescriptor<Digits>) descriptor;
		int integerDigits = digitsConstraint.getAnnotation().integer();
		int fractionalDigits = digitsConstraint.getAnnotation().fraction();
		Column col = (Column) property.getColumnIterator().next();
		col.setPrecision( integerDigits + fractionalDigits );
		col.setScale( fractionalDigits );
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:12,代码来源:TypeSafeActivator.java

示例5: buildJoinFromMappedBySide

import org.hibernate.mapping.Column; //导入方法依赖的package包/类
/**
 * Builds the <code>Join</code> instance for the mapped by side of a <i>OneToOne</i> association using 
 * a join tables.
 * <p>
 * Note:<br/>
 * <ul>
 * <li>From the mappedBy side we should not create the PK nor the FK, this is handled from the other side.</li>
 * <li>This method is a dirty dupe of EntityBinder.bindSecondaryTable</i>.
 * </p>
 */
private Join buildJoinFromMappedBySide(PersistentClass persistentClass, Property otherSideProperty, Join originalJoin) {
	Join join = new Join();
	join.setPersistentClass( persistentClass );

	//no check constraints available on joins
	join.setTable( originalJoin.getTable() );
	join.setInverse( true );
	SimpleValue key = new DependantValue( mappings, join.getTable(), persistentClass.getIdentifier() );
	//TODO support @ForeignKey
	join.setKey( key );
	join.setSequentialSelect( false );
	//TODO support for inverse and optional
	join.setOptional( true ); //perhaps not quite per-spec, but a Good Thing anyway
	key.setCascadeDeleteEnabled( false );
	Iterator mappedByColumns = otherSideProperty.getValue().getColumnIterator();
	while ( mappedByColumns.hasNext() ) {
		Column column = (Column) mappedByColumns.next();
		Column copy = new Column();
		copy.setLength( column.getLength() );
		copy.setScale( column.getScale() );
		copy.setValue( key );
		copy.setName( column.getQuotedName() );
		copy.setNullable( column.isNullable() );
		copy.setPrecision( column.getPrecision() );
		copy.setUnique( column.isUnique() );
		copy.setSqlType( column.getSqlType() );
		copy.setCheckConstraint( column.getCheckConstraint() );
		copy.setComment( column.getComment() );
		copy.setDefaultValue( column.getDefaultValue() );
		key.addColumn( copy );
	}
	persistentClass.addJoin( join );
	return join;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:45,代码来源:OneToOneSecondPass.java

示例6: createColumn

import org.hibernate.mapping.Column; //导入方法依赖的package包/类
protected Column createColumn(Mappings mappings,
                            Table tab,
                            com.manydesigns.portofino.model.database.Column column) {
    Column col = new Column();
    col.setName(quoteIdentifier(column.getColumnName()));
    if(column.getLength() != null) {
        col.setLength(column.getLength());
        col.setPrecision(column.getLength());
    }
    if(column.getScale() != null) {
        col.setScale(column.getScale());
    }
    col.setNullable(column.isNullable());
    String columnType = column.getColumnType();
    int jdbcType = column.getJdbcType();

    col.setSqlTypeCode(jdbcType);
    col.setSqlType(columnType);

    SimpleValue value = new SimpleValue(mappings, tab);
    if (!setHibernateType(value, column)) {
        logger.error("Skipping column {}", column.getQualifiedName());
        return null;
    }

    value.addColumn(col);
    tab.addColumn(col);
    mappings.addColumnBinding(column.getColumnName(), col, tab);

    return col;
}
 
开发者ID:ManyDesigns,项目名称:Portofino,代码行数:32,代码来源:HibernateConfig.java

示例7: createColumn

import org.hibernate.mapping.Column; //导入方法依赖的package包/类
protected Column createColumn(Mappings mappings,
                            Table tab,
                            com.manydesigns.portofino.model.database.Column column) {
    Column col = new Column();
    col.setName(escapeName(column.getColumnName()));
    col.setLength(column.getLength());
    col.setPrecision(column.getLength());
    col.setScale(column.getScale());
    col.setNullable(column.isNullable());
    String columnType = column.getColumnType();
    int jdbcType = column.getJdbcType();

    col.setSqlTypeCode(jdbcType);
    col.setSqlType(columnType);

    SimpleValue value = new SimpleValue(mappings, tab);
    if (!setHibernateType(value, column, column.getActualJavaType(), jdbcType)) {
        logger.error("Skipping column {}", column.getQualifiedName());
        return null;
    }

    value.addColumn(col);
    tab.addColumn(col);
    mappings.addColumnBinding(column.getColumnName(), col, tab);

    return col;
}
 
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:28,代码来源:HibernateConfig.java


注:本文中的org.hibernate.mapping.Column.setScale方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。