本文整理汇总了Java中org.hibernate.persister.entity.AbstractEntityPersister.getKeyColumnNames方法的典型用法代码示例。如果您正苦于以下问题:Java AbstractEntityPersister.getKeyColumnNames方法的具体用法?Java AbstractEntityPersister.getKeyColumnNames怎么用?Java AbstractEntityPersister.getKeyColumnNames使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.hibernate.persister.entity.AbstractEntityPersister
的用法示例。
在下文中一共展示了AbstractEntityPersister.getKeyColumnNames方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPropertyColumnNames
import org.hibernate.persister.entity.AbstractEntityPersister; //导入方法依赖的package包/类
/**
* Get the column names for a given property as an array of unbracketed,
* lowercase names. For a collection property, the column name is the inverse foreign key (i.e.
* the column on the other table that points back to the persister's table)
*/
String[] getPropertyColumnNames(AbstractEntityPersister persister, String propertyName, Type propType) {
String[] propColumnNames = null;
if (propType.isCollectionType()) {
propColumnNames = ((CollectionType) propType).getAssociatedJoinable((SessionFactoryImplementor) this._sessionFactory)
.getKeyColumnNames();
} else {
propColumnNames = persister.getPropertyColumnNames(propertyName);
}
if (propColumnNames == null || propColumnNames.length == 0) {
// this happens when the property is part of the key
propColumnNames = persister.getKeyColumnNames();
}
// HACK for formula: when using formula propColumnNames[0] equals null
if (propColumnNames[0] == null)
{
propColumnNames = new String[] { propertyName };
}
return unBracket(propColumnNames);
}
示例2: getPropertyColumnNames
import org.hibernate.persister.entity.AbstractEntityPersister; //导入方法依赖的package包/类
/**
* Get the column names for a given property as a comma-delimited String of unbracketed, lowercase names.
*/
String getPropertyColumnNames(AbstractEntityPersister persister, String propertyName) {
String propColumnNames[] = persister.getPropertyColumnNames(propertyName);
if (propColumnNames.length == 0) {
// this happens when the property is part of the key
propColumnNames = persister.getKeyColumnNames();
}
StringBuilder sb = new StringBuilder();
for (String s : propColumnNames) {
if (sb.length() > 0) sb.append(',');
sb.append(unBracket(s));
}
return sb.toString().toLowerCase();
}
示例3: getPropertyNamesForColumns
import org.hibernate.persister.entity.AbstractEntityPersister; //导入方法依赖的package包/类
/**
* Gets the properties matching the given columns. May be a component, but will not be an association.
* @param persister
* @param columnNames
* @return
*/
static String[] getPropertyNamesForColumns(AbstractEntityPersister persister, String[] columnNames) {
String[] propNames = persister.getPropertyNames();
Type[] propTypes = persister.getPropertyTypes();
for (int i = 0; i < propNames.length; i++) {
String propName = propNames[i];
Type propType = propTypes[i];
if (propType.isAssociationType()) continue;
String[] columnArray = persister.getPropertyColumnNames(i);
if (namesEqual(columnArray, columnNames)) return new String[] { propName };
}
// If we got here, maybe the property is the identifier
String[] keyColumnArray = persister.getKeyColumnNames();
if (namesEqual(keyColumnArray, columnNames))
{
if (persister.getIdentifierPropertyName() != null)
{
return new String[] { persister.getIdentifierPropertyName() };
}
if (persister.getIdentifierType().isComponentType())
{
ComponentType compType = (ComponentType) persister.getIdentifierType();
return compType.getPropertyNames();
}
}
if (columnNames.length > 1)
{
// go one-by-one through columnNames, trying to find a matching property.
// TODO: maybe this should split columnNames into all possible combinations of ordered subsets, and try those
ArrayList<String> propList = new ArrayList<String>();
String[] prop = new String[1];
for (int i = 0; i < columnNames.length; i++)
{
prop[0] = columnNames[i];
String[] names = getPropertyNamesForColumns(persister, prop); // recursive call
if (names != null) propList.addAll(Arrays.asList(names));
}
if (propList.size() > 0) return (String[]) propList.toArray();
}
return null;
}