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


Java Column.setName方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: createM2O

import org.hibernate.mapping.Column; //导入方法依赖的package包/类
protected ToOne createM2O(Configuration config, Mappings mappings,
                         ForeignKey relationship) {
    com.manydesigns.portofino.model.database.Table manyMDTable =
            relationship.getFromTable();
    com.manydesigns.portofino.model.database.Table oneMDTable =
            relationship.getToTable();
    String manyMDQualifiedTableName = manyMDTable.getActualEntityName();
    String oneMDQualifiedTableName = oneMDTable.getActualEntityName();

    RootClass clazz =
            (RootClass) mappings.getClass(manyMDQualifiedTableName);
    if(clazz == null) {
        logger.error("Cannot find table '{}' as 'many' side of foreign key '{}'. Skipping relationship.",
                manyMDQualifiedTableName, relationship.getName());
        return null;
    }

    Table tab = clazz.getTable();

    ManyToOne m2o = new ManyToOne(mappings, tab);
    m2o.setLazy(LAZY);
    final HashMap<String, PersistentClass> persistentClasses = new HashMap<String, PersistentClass>();
    persistentClasses.put(oneMDQualifiedTableName,
            config.getClassMapping(oneMDQualifiedTableName));
    m2o.setReferencedEntityName(oneMDQualifiedTableName);
    m2o.setForeignKeyName(relationship.getQualifiedName());

    PersistentClass manyClass = config.getClassMapping(manyMDQualifiedTableName);
    Set<com.manydesigns.portofino.model.database.Column> referencedColumns =
            new HashSet<com.manydesigns.portofino.model.database.Column>();
    for (Reference ref : relationship.getReferences()) {
        com.manydesigns.portofino.model.database.Column fromColumn = ref.getActualFromColumn();
        if(fromColumn == null) {
            logger.error("Missing from column {}, skipping relationship", ref.getFromColumn());
            return null;
        }
        Column col = new Column();
        col.setName(quoteIdentifier(fromColumn.getColumnName()));
        //Recupero la colonna precedentemente associata alla tabella:
        //essa ha uno uniqueIdentifier generato al momento dell'associazione alla tabella;
        //questo viene utilizzato per disambiguare l'alias della colonna nelle query
        //SQL generate da Hibernate.
        col = manyClass.getTable().getColumn(col);
        if(col == null) {
            logger.error("Column not found in 'many' entity {}: {}, " +
                         "skipping relationship", manyClass.getEntityName(), fromColumn.getColumnName());
            return null;
        }
        m2o.addColumn(col);
        //Is the relationship a reference to the primary key or to a unique key?
        referencedColumns.add(ref.getActualToColumn());
    }
    List<?> pkColumns = oneMDTable.getPrimaryKey().getColumns();
    boolean referenceToPrimaryKey =
            pkColumns.containsAll(referencedColumns) && pkColumns.size() == referencedColumns.size();
    m2o.setReferenceToPrimaryKey(referenceToPrimaryKey);
    if(!referenceToPrimaryKey) {
        logger.debug("Foreign key {} is not a reference to the primary key. Creating synthetic property.",
                relationship.getName());
        try {
            addSyntheticProperty(mappings, m2o, relationship, oneMDTable, oneMDQualifiedTableName);
        } catch (Exception e) {
            logger.error("Unsupported reference to columns outside the primary key, skipping relationship: " +
                    relationship.getName(), e);
            return null;
        }
    }
    m2o.createForeignKey();
    m2o.createPropertyRefConstraints(persistentClasses);

    Property prop = new Property();
    prop.setName(relationship.getActualOnePropertyName());
    prop.setValue(m2o);
    prop.setCascade("none"); //TODO era "all", capire
    prop.setInsertable(false);
    prop.setUpdateable(false);
    clazz.addProperty(prop);
    return m2o;
}
 
开发者ID:ManyDesigns,项目名称:Portofino,代码行数:80,代码来源:HibernateConfig.java

示例6: createM2O

import org.hibernate.mapping.Column; //导入方法依赖的package包/类
protected void createM2O(Configuration config, Mappings mappings,
                         ForeignKey relationship) {
    com.manydesigns.portofino.model.database.Table manyMDTable =
            relationship.getFromTable();
    com.manydesigns.portofino.model.database.Table oneMDTable =
            relationship.getToTable();
    String manyMDQualifiedTableName = manyMDTable.getActualEntityName();
    String oneMDQualifiedTableName = oneMDTable.getActualEntityName();

    RootClass clazz =
            (RootClass) mappings.getClass(manyMDQualifiedTableName);
    if(clazz == null) {
        logger.error("Cannot find table '{}' as 'many' side of foreign key '{}'. Skipping relationship.",
                manyMDQualifiedTableName, relationship.getName());
        return;
    }

    Table tab = clazz.getTable();
    List<String> columnNames = new ArrayList<String>();

    for (Reference ref : relationship.getReferences()) {
        if(ref.getActualFromColumn() == null) {
            logger.error("Missing from column {}, skipping relationship", ref.getFromColumn());
            return;
        }
        columnNames.add(ref.getFromColumn());
    }

    ManyToOne m2o = new ManyToOne(mappings, tab);
    m2o.setLazy(LAZY);
    final HashMap<String, PersistentClass> persistentClasses =
            new HashMap<String, PersistentClass>();
    persistentClasses.put(oneMDQualifiedTableName,
            config.getClassMapping(oneMDQualifiedTableName));
    m2o.setReferencedEntityName(oneMDQualifiedTableName);
    m2o.createPropertyRefConstraints(persistentClasses);

    PersistentClass manyClass = config.getClassMapping(manyMDQualifiedTableName);
    for (String columnName : columnNames) {
        Column col = new Column();
        col.setName(escapeName(columnName));
        //Recupero la colonna precedentemente associata alla tabella:
        //essa ha uno uniqueIdentifier generato al momento dell'associazione alla tabella;
        //questo viene utilizzato per disambiguare l'alias della colonna nelle query
        //SQL generate da Hibernate.
        col = manyClass.getTable().getColumn(col);
        if(col == null) {
            logger.error("Column not found in 'many' entity {}: {}, " +
                         "skipping relationship", manyClass.getEntityName(), columnName);
            return;
        }
        m2o.addColumn(col);
    }

    Property prop = new Property();
    prop.setName(relationship.getActualOnePropertyName());
    //prop.setNodeName(relationship.getActualOnePropertyName());
    prop.setValue(m2o);
    prop.setCascade("none"); //TODO era "all", capire
    prop.setInsertable(false);
    prop.setUpdateable(false);
    clazz.addProperty(prop);
}
 
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:64,代码来源:HibernateConfig.java


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