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


Java Column类代码示例

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


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

示例1: getModifyColumnSql

import org.hibernate.mapping.Column; //导入依赖的package包/类
@Override
public String getModifyColumnSql(Mapping mapping, Column column, boolean changeNotNull, boolean changeType)
{
	String columnName = column.getQuotedName(this);

	String nullStr = "";
	if( changeNotNull )
	{
		nullStr = column.isNullable() ? " NULL" : " NOT NULL";
	}
	String typeStr = "";
	if( changeType )
	{
		typeStr = ' ' + column.getSqlType(this, mapping);
	}

	return "MODIFY (" + columnName + typeStr + nullStr + ")";
}
 
开发者ID:equella,项目名称:Equella,代码行数:19,代码来源:ExtendedOracle10gDialect.java

示例2: getModifyColumnSql

import org.hibernate.mapping.Column; //导入依赖的package包/类
@Override
public String getModifyColumnSql(Mapping mapping, Column column, boolean changeNotNull, boolean changeType)
{
	StringBuilder sbuf = new StringBuilder();
	String columnName = column.getQuotedName(this);

	if( changeNotNull )
	{
		sbuf.append("ALTER COLUMN ");
		sbuf.append(columnName).append(' ');
		sbuf.append(column.isNullable() ? "DROP" : "SET");
		sbuf.append(" NOT NULL");
	}
	if( changeType )
	{
		if( changeNotNull )
		{
			sbuf.append(", ");
		}
		sbuf.append("ALTER COLUMN ");
		sbuf.append(columnName).append(" TYPE ").append(column.getSqlType(this, mapping));
	}
	return sbuf.toString();
}
 
开发者ID:equella,项目名称:Equella,代码行数:25,代码来源:ExtendedPostgresDialect.java

示例3: addIndexSQL

import org.hibernate.mapping.Column; //导入依赖的package包/类
@SuppressWarnings({"unchecked"})
private void addIndexSQL(List<String> sqlStrings, Table table, Set<Column> colSet)
{
	Iterator<Index> indexIterator = table.getIndexIterator();
	while( indexIterator.hasNext() )
	{
		Index index = indexIterator.next();
		Iterator<Column> colIter = index.getColumnIterator();
		boolean found = false;
		while( colIter.hasNext() )
		{
			Column col = colIter.next();
			if( colSet.contains(col) )
			{
				found = true;
				break;
			}
		}
		if( found && (!extDialect.supportsAutoIndexForUniqueColumn() || !hasUniqueIndex(index, table)) )
		{
			sqlStrings.add(index.sqlCreateString(dialect, mapping, defaultCatalog, defaultSchema));
		}
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:25,代码来源:HibernateMigrationHelper.java

示例4: hasUniqueIndex

import org.hibernate.mapping.Column; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private boolean hasUniqueIndex(Index index, Table table)
{
	HashSet<Column> indexCols = new HashSet<Column>();
	Iterator<Column> icolIter = index.getColumnIterator();
	while( icolIter.hasNext() )
	{
		Column col = icolIter.next();
		indexCols.add(col);
		if( index.getColumnSpan() == 1 && table.getColumn(col).isUnique() )
		{
			return true;
		}
	}
	Iterator<UniqueKey> iter = table.getUniqueKeyIterator();
	while( iter.hasNext() )
	{
		UniqueKey uk = iter.next();
		if( uk.getColumnSpan() == indexCols.size() && indexCols.containsAll(uk.getColumns()) )
		{
			return true;
		}
	}
	return false;
}
 
开发者ID:equella,项目名称:Equella,代码行数:26,代码来源:HibernateMigrationHelper.java

示例5: getModifyColumnSQL

import org.hibernate.mapping.Column; //导入依赖的package包/类
/**
 * @param tableName
 * @param columnName
 * @param changeNotNull
 * @param nullable Pass in null to use the annotation on the column. This is
 *            not always possible (see Redmine #3329).
 * @param changeType
 * @return
 */
public List<String> getModifyColumnSQL(String tableName, String columnName, boolean changeNotNull,
	boolean changeType)
{
	List<String> sqlStrings = new ArrayList<String>();

	Table table = findTable(tableName);
	Column column = table.getColumn(new Column(columnName));

	StringBuffer alter = new StringBuffer("alter table ")
		.append(table.getQualifiedName(dialect, defaultCatalog, defaultSchema)).append(' ')
		.append(extDialect.getModifyColumnSql(mapping, column, changeNotNull, changeType));

	sqlStrings.add(alter.toString());
	return sqlStrings;
}
 
开发者ID:equella,项目名称:Equella,代码行数:25,代码来源:HibernateMigrationHelper.java

示例6: getDropColumnSQL

import org.hibernate.mapping.Column; //导入依赖的package包/类
public List<String> getDropColumnSQL(String tableName, String... columns)
{
	List<String> sqlStrings = new ArrayList<String>();

	Table table = findTable(tableName);
	for( String columnName : columns )
	{
		Column column = table.getColumn(new Column(columnName));
		if( column == null )
		{
			throw new RuntimeException("Could not find column " + columnName + " on table " + tableName);
		}
		sqlStrings.add(extDialect.getDropColumnSql(table.getQualifiedName(dialect, defaultCatalog, defaultSchema),
			column));
	}
	return sqlStrings;
}
 
开发者ID:equella,项目名称:Equella,代码行数:18,代码来源:HibernateMigrationHelper.java

示例7: getAddNotNullSQL

import org.hibernate.mapping.Column; //导入依赖的package包/类
public List<String> getAddNotNullSQL(String tableName, String... columns)
{
	List<String> sqlStrings = new ArrayList<String>();

	Table table = findTable(tableName);
	for( String columnName : columns )
	{
		Column column = table.getColumn(new Column(columnName));

		StringBuffer alter = new StringBuffer("alter table ")
			.append(table.getQualifiedName(dialect, defaultCatalog, defaultSchema)).append(' ')
			.append(extDialect.getAddNotNullSql(mapping, column));
		sqlStrings.add(alter.toString());
	}
	return sqlStrings;
}
 
开发者ID:equella,项目名称:Equella,代码行数:17,代码来源:HibernateMigrationHelper.java

示例8: getAddIndexesRawIfRequired

import org.hibernate.mapping.Column; //导入依赖的package包/类
public Collection<? extends String> getAddIndexesRawIfRequired(Session session, String tableName,
	String[]... indexes)
{
	List<String> sqlStrings = new ArrayList<String>();
	final Table table = findTable(tableName);
	Map<Set<String>, String> revIndexMap = getExistingIndexes(table, session);
	for( String[] index : indexes )
	{
		Index indexObj = new Index();
		indexObj.setTable(table);
		indexObj.setName(index[0]);
		for( int i = 1; i < index.length; i++ )
		{
			Column col = new Column(index[i]);
			indexObj.addColumn(col);
		}
		processIndex(table, indexObj, revIndexMap, sqlStrings);
	}
	return sqlStrings;
}
 
开发者ID:equella,项目名称:Equella,代码行数:21,代码来源:HibernateMigrationHelper.java

示例9: getAddIndexesRaw

import org.hibernate.mapping.Column; //导入依赖的package包/类
public Collection<? extends String> getAddIndexesRaw(String tableName, String[]... indexes)
{
	List<String> sqlStrings = new ArrayList<String>();
	final Table table = findTable(tableName);
	for( String[] index : indexes )
	{
		Index indexObj = new Index();
		indexObj.setTable(table);
		indexObj.setName(index[0]);
		for( int i = 1; i < index.length; i++ )
		{
			Column col = new Column(index[i]);
			indexObj.addColumn(col);
		}
		sqlStrings.add(indexObj.sqlCreateString(dialect, mapping, defaultCatalog, defaultSchema));
	}
	return sqlStrings;
}
 
开发者ID:equella,项目名称:Equella,代码行数:19,代码来源:HibernateMigrationHelper.java

示例10: processIndex

import org.hibernate.mapping.Column; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void processIndex(Table table, Index index, Map<Set<String>, String> revIndexMap, List<String> sqlStrings)
{
	Iterator<Column> colIter = index.getColumnIterator();
	Set<String> indexCols = new HashSet<String>();
	while( colIter.hasNext() )
	{
		Column col = colIter.next();
		indexCols.add(col.getName().toLowerCase());
	}
	String existingIndex = revIndexMap.get(indexCols);
	if( existingIndex != null )
	{
		if( existingIndex.equalsIgnoreCase(index.getName()) )
		{
			return;
		}
		else
		{
			sqlStrings.add(extDialect.getDropIndexSql(table.getName(), '`' + existingIndex + '`'));
		}
	}
	sqlStrings.add(index.sqlCreateString(dialect, mapping, defaultCatalog, defaultSchema));
}
 
开发者ID:equella,项目名称:Equella,代码行数:25,代码来源:HibernateMigrationHelper.java

示例11: addConstraintToColumn

import org.hibernate.mapping.Column; //导入依赖的package包/类
private void addConstraintToColumn(final String columnName ) {
	Column column = table.getColumn(
			new Column(
					mappings.getPhysicalColumnName( columnName, table )
			)
	);
	if ( column == null ) {
		throw new AnnotationException(
				"@Index references a unknown column: " + columnName
		);
	}
	if ( unique )
		table.getOrCreateUniqueKey( indexName ).addColumn( column );
	else
		table.getOrCreateIndex( indexName ).addColumn( column );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:IndexOrUniqueKeySecondPass.java

示例12: bindLogicalToPhysical

import org.hibernate.mapping.Column; //导入依赖的package包/类
private void bindLogicalToPhysical(String logicalName, Column physicalColumn) throws DuplicateMappingException {
	final String logicalKey = logicalName.toLowerCase();
	final String physicalName = physicalColumn.getQuotedName();
	final String existingPhysicalName = ( String ) logicalToPhysical.put( logicalKey, physicalName );
	if ( existingPhysicalName != null ) {
		boolean areSamePhysicalColumn = physicalColumn.isQuoted()
				? existingPhysicalName.equals( physicalName )
				: existingPhysicalName.equalsIgnoreCase( physicalName );
		if ( ! areSamePhysicalColumn ) {
			throw new DuplicateMappingException(
					" Table [" + tableName + "] contains logical column name [" + logicalName
							+ "] referenced by multiple physical column names: [" + existingPhysicalName
							+ "], [" + physicalName + "]",
					"column-binding",
					tableName + "." + logicalName
			);
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:Configuration.java

示例13: matchColumnsByProperty

import org.hibernate.mapping.Column; //导入依赖的package包/类
private static void matchColumnsByProperty(Property property, Map<Column, Set<Property>> columnsToProperty) {
		if ( property == null ) return;
		if ( "noop".equals( property.getPropertyAccessorName() )
				|| "embedded".equals( property.getPropertyAccessorName() ) ) {
			return;
		}
// FIXME cannot use subproperties becasue the caller needs top level properties
//		if ( property.isComposite() ) {
//			Iterator subProperties = ( (Component) property.getValue() ).getPropertyIterator();
//			while ( subProperties.hasNext() ) {
//				matchColumnsByProperty( (Property) subProperties.next(), columnsToProperty );
//			}
//		}
		else {
			Iterator columnIt = property.getColumnIterator();
			while ( columnIt.hasNext() ) {
				Object column = columnIt.next(); //can be a Formula so we don't cast
				//noinspection SuspiciousMethodCalls
				if ( columnsToProperty.containsKey( column ) ) {
					columnsToProperty.get( column ).add( property );
				}
			}
		}
	}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:25,代码来源:BinderHelper.java

示例14: linkValueUsingDefaultColumnNaming

import org.hibernate.mapping.Column; //导入依赖的package包/类
public void linkValueUsingDefaultColumnNaming(
		Column referencedColumn,
		PersistentClass referencedEntity,
		SimpleValue value) {
	String columnName;
	String logicalReferencedColumn = getMappings().getLogicalColumnName(
			referencedColumn.getQuotedName(), referencedEntity.getTable()
	);
	columnName = buildDefaultColumnName( referencedEntity, logicalReferencedColumn );
	//yuk side effect on an implicit column
	setLogicalColumnName( columnName );
	setReferencedColumn( logicalReferencedColumn );
	initMappingColumn(
			columnName,
			null, referencedColumn.getLength(),
			referencedColumn.getPrecision(),
			referencedColumn.getScale(),
			getMappingColumn() != null ? getMappingColumn().isNullable() : false,
			referencedColumn.getSqlType(),
			getMappingColumn() != null ? getMappingColumn().isUnique() : false,
		    false
	);
	linkWithValue( value );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:25,代码来源:Ejb3JoinColumn.java

示例15: overrideFromReferencedColumnIfNecessary

import org.hibernate.mapping.Column; //导入依赖的package包/类
/**
 * 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());
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:Ejb3JoinColumn.java


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