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


Java CollectionType.getElementType方法代码示例

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

示例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;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:36,代码来源:Nullability.java

示例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;
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:37,代码来源:Nullability.java

示例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;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:49,代码来源:CriteriaQueryTranslator.java

示例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;
}
 
开发者ID:geodir,项目名称:Layer-Query,代码行数:49,代码来源:CustomCriteriaQueryTranslator.java

示例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 );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:12,代码来源:SessionFactoryHelper.java

示例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 );
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:11,代码来源:SessionFactoryHelper.java


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