本文整理匯總了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;
}
}