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


Java PersistentClass.getTable方法代码示例

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


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

示例1: checkReferencedColumnsType

import org.hibernate.mapping.PersistentClass; //导入方法依赖的package包/类
public static int checkReferencedColumnsType(
		Ejb3JoinColumn[] columns,
		PersistentClass referencedEntity,
		Mappings mappings) {
	//convenient container to find whether a column is an id one or not
	Set<Column> idColumns = new HashSet<Column>();
	Iterator idColumnsIt = referencedEntity.getKey().getColumnIterator();
	while ( idColumnsIt.hasNext() ) {
		idColumns.add( (Column) idColumnsIt.next() );
	}

	boolean isFkReferencedColumnName = false;
	boolean noReferencedColumn = true;
	//build the list of potential tables
	if ( columns.length == 0 ) return NO_REFERENCE; //shortcut
	Object columnOwner = BinderHelper.findColumnOwner(
			referencedEntity, columns[0].getReferencedColumn(), mappings
	);
	if ( columnOwner == null ) {
		try {
			throw new MappingException(
					"Unable to find column with logical name: "
							+ columns[0].getReferencedColumn() + " in " + referencedEntity.getTable() + " and its related "
							+ "supertables and secondary tables"
			);
		}
		catch (MappingException e) {
			throw new RecoverableException( e.getMessage(), e );
		}
	}
	Table matchingTable = columnOwner instanceof PersistentClass ?
			( (PersistentClass) columnOwner ).getTable() :
			( (Join) columnOwner ).getTable();
	//check each referenced column
	for (Ejb3JoinColumn ejb3Column : columns) {
		String logicalReferencedColumnName = ejb3Column.getReferencedColumn();
		if ( StringHelper.isNotEmpty( logicalReferencedColumnName ) ) {
			String referencedColumnName;
			try {
				referencedColumnName = mappings.getPhysicalColumnName( logicalReferencedColumnName, matchingTable );
			}
			catch (MappingException me) {
				//rewrite the exception
				throw new MappingException(
						"Unable to find column with logical name: "
								+ logicalReferencedColumnName + " in " + matchingTable.getName()
				);
			}
			noReferencedColumn = false;
			Column refCol = new Column( referencedColumnName );
			boolean contains = idColumns.contains( refCol );
			if ( !contains ) {
				isFkReferencedColumnName = true;
				break; //we know the state
			}
		}
	}
	if ( isFkReferencedColumnName ) {
		return NON_PK_REFERENCE;
	}
	else if ( noReferencedColumn ) {
		return NO_REFERENCE;
	}
	else if ( idColumns.size() != columns.length ) {
		//reference use PK but is a subset or a superset
		return NON_PK_REFERENCE;
	}
	else {
		return PK_REFERENCE;
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:72,代码来源:Ejb3JoinColumn.java


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