本文整理汇总了Java中org.hibernate.type.CollectionType.getElementType方法的典型用法代码示例。如果您正苦于以下问题:Java CollectionType.getElementType方法的具体用法?Java CollectionType.getElementType怎么用?Java CollectionType.getElementType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.hibernate.type.CollectionType
的用法示例。
在下文中一共展示了CollectionType.getElementType方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addAssociationsToTheSetForOneProperty
import org.hibernate.type.CollectionType; //导入方法依赖的package包/类
private void addAssociationsToTheSetForOneProperty(String name, Type type, String prefix, SessionFactoryImplementor factory) {
if ( type.isCollectionType() ) {
CollectionType collType = (CollectionType) type;
Type assocType = collType.getElementType( factory );
addAssociationsToTheSetForOneProperty(name, assocType, prefix, factory);
}
//ToOne association
else if ( type.isEntityType() || type.isAnyType() ) {
associations.add( prefix + name );
} else if ( type.isComponentType() ) {
CompositeType componentType = (CompositeType) type;
addAssociationsToTheSetForAllProperties(
componentType.getPropertyNames(),
componentType.getSubtypes(),
(prefix.equals( "" ) ? name : prefix + name) + ".",
factory);
}
}
示例2: checkSubElementsNullability
import org.hibernate.type.CollectionType; //导入方法依赖的package包/类
/**
* check sub elements-nullability. Returns property path that break
* nullability or null if none
*
* @param propertyType type to check
* @param value value to check
*
* @return property path
* @throws HibernateException error while getting subcomponent values
*/
private String checkSubElementsNullability(Type propertyType, Object value) throws HibernateException {
if ( propertyType.isComponentType() ) {
return checkComponentNullability( value, (CompositeType) propertyType );
}
if ( propertyType.isCollectionType() ) {
// persistent collections may have components
final CollectionType collectionType = (CollectionType) propertyType;
final Type collectionElementType = collectionType.getElementType( session.getFactory() );
if ( collectionElementType.isComponentType() ) {
// check for all components values in the collection
final CompositeType componentType = (CompositeType) collectionElementType;
final Iterator itr = CascadingActions.getLoadedElementsIterator( session, collectionType, value );
while ( itr.hasNext() ) {
final Object compositeElement = itr.next();
if ( compositeElement != null ) {
return checkComponentNullability( compositeElement, componentType );
}
}
}
}
return null;
}
示例3: checkSubElementsNullability
import org.hibernate.type.CollectionType; //导入方法依赖的package包/类
/**
* check sub elements-nullability. Returns property path that break
* nullability or null if none
*
* @param propertyType type to check
* @param value value to check
*
* @return property path
* @throws HibernateException error while getting subcomponent values
*/
private String checkSubElementsNullability(final Type propertyType, final Object value)
throws HibernateException {
//for non null args, check for components and elements containing components
if ( propertyType.isComponentType() ) {
return checkComponentNullability( value, (AbstractComponentType) propertyType );
}
else if ( propertyType.isCollectionType() ) {
//persistent collections may have components
CollectionType collectionType = (CollectionType) propertyType;
Type collectionElementType = collectionType.getElementType( session.getFactory() );
if ( collectionElementType.isComponentType() ) {
//check for all components values in the collection
AbstractComponentType componentType = (AbstractComponentType) collectionElementType;
Iterator iter = CascadingAction.getLoadedElementsIterator(session, collectionType, value);
while ( iter.hasNext() ) {
Object compValue = iter.next();
if (compValue != null) {
return checkComponentNullability(compValue, componentType);
}
}
}
}
return null;
}
示例4: getPathInfo
import org.hibernate.type.CollectionType; //导入方法依赖的package包/类
private CriteriaInfoProvider getPathInfo(String path) {
StringTokenizer tokens = new StringTokenizer( path, "." );
String componentPath = "";
// start with the 'rootProvider'
CriteriaInfoProvider provider = nameCriteriaInfoMap.get( rootEntityName );
while ( tokens.hasMoreTokens() ) {
componentPath += tokens.nextToken();
final Type type = provider.getType( componentPath );
if ( type.isAssociationType() ) {
// CollectionTypes are always also AssociationTypes - but there's not always an associated entity...
final AssociationType atype = (AssociationType) type;
final CollectionType ctype = type.isCollectionType() ? (CollectionType)type : null;
final Type elementType = (ctype != null) ? ctype.getElementType( sessionFactory ) : null;
// is the association a collection of components or value-types? (i.e a colloction of valued types?)
if ( ctype != null && elementType.isComponentType() ) {
provider = new ComponentCollectionCriteriaInfoProvider( helper.getCollectionPersister(ctype.getRole()) );
}
else if ( ctype != null && !elementType.isEntityType() ) {
provider = new ScalarCollectionCriteriaInfoProvider( helper, ctype.getRole() );
}
else {
provider = new EntityCriteriaInfoProvider(
(Queryable) sessionFactory.getEntityPersister( atype.getAssociatedEntityName( sessionFactory ) )
);
}
componentPath = "";
}
else if ( type.isComponentType() ) {
if (!tokens.hasMoreTokens()) {
throw new QueryException(
"Criteria objects cannot be created directly on components. Create a criteria on " +
"owning entity and use a dotted property to access component property: " + path
);
}
else {
componentPath += '.';
}
}
else {
throw new QueryException( "not an association: " + componentPath );
}
}
return provider;
}
示例5: getPathInfo
import org.hibernate.type.CollectionType; //导入方法依赖的package包/类
private CriteriaInfoProvider getPathInfo(String path) {
StringTokenizer tokens = new StringTokenizer( path, "." );
String componentPath = "";
// start with the 'rootProvider'
CriteriaInfoProvider provider = nameCriteriaInfoMap.get( rootEntityName );
while ( tokens.hasMoreTokens() ) {
componentPath += tokens.nextToken();
final Type type = provider.getType( componentPath );
if ( type.isAssociationType() ) {
// CollectionTypes are always also AssociationTypes - but there's not always an associated entity...
final AssociationType atype = (AssociationType) type;
final CollectionType ctype = type.isCollectionType() ? (CollectionType) type : null;
final Type elementType = ( ctype != null ) ? ctype.getElementType( sessionFactory ) : null;
// is the association a collection of components or value-types? (i.e a colloction of valued types?)
if ( ctype != null && elementType.isComponentType() ) {
provider = new ComponentCollectionCriteriaInfoProvider( helper.getCollectionPersister( ctype.getRole() ) );
}
else if ( ctype != null && !elementType.isEntityType() ) {
provider = new ScalarCollectionCriteriaInfoProvider( helper, ctype.getRole() );
}
else {
provider = new EntityCriteriaInfoProvider(
(Queryable) sessionFactory.getEntityPersister( atype.getAssociatedEntityName( sessionFactory ) )
);
}
componentPath = "";
}
else if ( type.isComponentType() ) {
if ( !tokens.hasMoreTokens() ) {
throw new QueryException(
"Criteria objects cannot be created directly on components. Create a criteria on " +
"owning entity and use a dotted property to access component property: " + path
);
}
else {
componentPath += '.';
}
}
else {
throw new QueryException( "not an association: " + componentPath );
}
}
return provider;
}
示例6: getElementType
import org.hibernate.type.CollectionType; //导入方法依赖的package包/类
/**
* Given a collection type, determine the Type representing elements
* within instances of that collection.
*
* @param collectionType The collection type to be checked.
*
* @return The Type of the elements of the collection.
*/
private Type getElementType(CollectionType collectionType) {
return collectionType.getElementType( sfi );
}
示例7: getElementType
import org.hibernate.type.CollectionType; //导入方法依赖的package包/类
/**
* Given a collection type, determine the Type representing elements
* within instances of that collection.
*
* @param collectionType The collection type to be checked.
* @return The Type of the elements of the collection.
*/
private Type getElementType(CollectionType collectionType) {
return collectionType.getElementType( sfi );
}