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


Java AbstractEntityPersister.getKeyColumnNames方法代码示例

本文整理汇总了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);
}
 
开发者ID:Breeze,项目名称:breeze.server.java,代码行数:26,代码来源:HibernateMetadata.java

示例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();
}
 
开发者ID:smysnk,项目名称:dockyard-controller,代码行数:18,代码来源:MetadataBuilder.java

示例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;

}
 
开发者ID:Breeze,项目名称:breeze.server.java,代码行数:52,代码来源:HibernateMetadata.java


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