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


Java Type.isCollectionType方法代码示例

本文整理汇总了Java中org.hibernate.type.Type.isCollectionType方法的典型用法代码示例。如果您正苦于以下问题:Java Type.isCollectionType方法的具体用法?Java Type.isCollectionType怎么用?Java Type.isCollectionType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.hibernate.type.Type的用法示例。


在下文中一共展示了Type.isCollectionType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addAssociationsToTheSetForOneProperty

import org.hibernate.type.Type; //导入方法依赖的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: getQueryableCollection

import org.hibernate.type.Type; //导入方法依赖的package包/类
protected QueryableCollection getQueryableCollection(
		String entityName,
		String propertyName,
		SessionFactoryImplementor factory) throws HibernateException {
	final PropertyMapping ownerMapping = (PropertyMapping) factory.getEntityPersister( entityName );
	final Type type = ownerMapping.toType( propertyName );
	if ( !type.isCollectionType() ) {
		throw new MappingException(
				"Property path [" + entityName + "." + propertyName + "] does not reference a collection"
		);
	}

	final String role = ( (CollectionType) type ).getRole();
	try {
		return (QueryableCollection) factory.getCollectionPersister( role );
	}
	catch ( ClassCastException cce ) {
		throw new QueryException( "collection role is not queryable: " + role );
	}
	catch ( Exception e ) {
		throw new QueryException( "collection role not found: " + role );
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:24,代码来源:AbstractEmptinessExpression.java

示例3: getSubclassPropertyTableNumber

import org.hibernate.type.Type; //导入方法依赖的package包/类
/**
 * Warning:
 * When there are duplicated property names in the subclasses
 * of the class, this method may return the wrong table
 * number for the duplicated subclass property (note that
 * SingleTableEntityPersister defines an overloaded form
 * which takes the entity name.
 */
public int getSubclassPropertyTableNumber(String propertyPath) {
	String rootPropertyName = StringHelper.root(propertyPath);
	Type type = propertyMapping.toType(rootPropertyName);
	if ( type.isAssociationType() ) {
		AssociationType assocType = ( AssociationType ) type;
		if ( assocType.useLHSPrimaryKey() ) {
			// performance op to avoid the array search
			return 0;
		}
		else if ( type.isCollectionType() ) {
			// properly handle property-ref-based associations
			rootPropertyName = assocType.getLHSPropertyName();
		}
	}
	//Enable for HHH-440, which we don't like:
	/*if ( type.isComponentType() && !propertyName.equals(rootPropertyName) ) {
		String unrooted = StringHelper.unroot(propertyName);
		int idx = ArrayHelper.indexOf( getSubclassColumnClosure(), unrooted );
		if ( idx != -1 ) {
			return getSubclassColumnTableNumberClosure()[idx];
		}
	}*/
	int index = ArrayHelper.indexOf( getSubclassPropertyNameClosure(), rootPropertyName); //TODO: optimize this better!
	return index==-1 ? 0 : getSubclassPropertyTableNumber(index);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:34,代码来源:AbstractEntityPersister.java

示例4: decode

import org.hibernate.type.Type; //导入方法依赖的package包/类
private static NonIdentifierAttributeNature decode(Type type) {
	if ( type.isAssociationType() ) {
		AssociationType associationType = (AssociationType) type;

		if ( type.isComponentType() ) {
			// an any type is both an association and a composite...
			return NonIdentifierAttributeNature.ANY;
		}

		return type.isCollectionType()
				? NonIdentifierAttributeNature.COLLECTION
				: NonIdentifierAttributeNature.ENTITY;
	}
	else {
		if ( type.isComponentType() ) {
			return NonIdentifierAttributeNature.COMPOSITE;
		}

		return NonIdentifierAttributeNature.BASIC;
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:PropertyFactory.java

示例5: checkSubElementsNullability

import org.hibernate.type.Type; //导入方法依赖的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

示例6: processValue

import org.hibernate.type.Type; //导入方法依赖的package包/类
/**
 * Visit a property value. Dispatch to the
 * correct handler for the property type.
 * @param value
 * @param type
 * @throws HibernateException
 */
final Object processValue(Object value, Type type) throws HibernateException {

	if ( type.isCollectionType() ) {
		//even process null collections
		return processCollection( value, (CollectionType) type );
	}
	else if ( type.isEntityType() ) {
		return processEntity( value, (EntityType) type );
	}
	else if ( type.isComponentType() ) {
		return processComponent( value, (CompositeType) type );
	}
	else {
		return null;
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:24,代码来源:AbstractVisitor.java

示例7: end

import org.hibernate.type.Type; //导入方法依赖的package包/类
public void end(QueryTranslatorImpl q) throws QueryException {
	if ( !isCollectionValued() ) {
		Type type = getPropertyType();
		if ( type.isEntityType() ) {
			// "finish off" the join
			token( ".", q );
			token( null, q );
		}
		else if ( type.isCollectionType() ) {
			// default to element set if no elements() specified
			token( ".", q );
			token( CollectionPropertyNames.COLLECTION_ELEMENTS, q );
		}
	}
	super.end( q );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:FromPathExpressionParser.java

示例8: createCollectionJoin

import org.hibernate.type.Type; //导入方法依赖的package包/类
private FromElement createCollectionJoin(JoinSequence collectionJoinSequence, String tableAlias)
			throws SemanticException {
		String text = queryableCollection.getTableName();
		AST ast = createFromElement( text );
		FromElement destination = (FromElement) ast;
		Type elementType = queryableCollection.getElementType();
		if ( elementType.isCollectionType() ) {
			throw new SemanticException( "Collections of collections are not supported!" );
		}
		destination.initializeCollection( fromClause, classAlias, tableAlias );
		destination.setType( JOIN_FRAGMENT );        // Tag this node as a JOIN.
		destination.setIncludeSubclasses( false );    // Don't include subclasses in the join.
		destination.setCollectionJoin( true );        // This is a clollection join.
		destination.setJoinSequence( collectionJoinSequence );
		destination.setOrigin( origin, false );
		destination.setCollectionTableAlias( tableAlias );
//		origin.addDestination( destination );
// This was the cause of HHH-242
//		origin.setType( FROM_FRAGMENT );			// Set the parent node type so that the AST is properly formed.
		origin.setText( "" );                        // The destination node will have all the FROM text.
		origin.setCollectionJoin( true );            // The parent node is a collection join too (voodoo - see JoinProcessor)
		fromClause.addCollectionJoinFromElementByPath( path, destination );
		fromClause.getWalker().addQuerySpaces( queryableCollection.getCollectionSpaces() );
		return destination;
	}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:26,代码来源:FromElementFactory.java

示例9: end

import org.hibernate.type.Type; //导入方法依赖的package包/类
public void end(QueryTranslatorImpl q) throws QueryException {
	ignoreInitialJoin = false;

	Type propertyType = getPropertyType();
	if ( propertyType != null && propertyType.isCollectionType() ) {
		collectionRole = ( ( CollectionType ) propertyType ).getRole();
		collectionName = q.createNameForCollection( collectionRole );
		prepareForIndex( q );
	}
	else {
		columns = currentColumns();
		setType();
	}

	//important!!
	continuation = false;

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:19,代码来源:PathExpressionParser.java

示例10: getCascadeStyle

import org.hibernate.type.Type; //导入方法依赖的package包/类
public CascadeStyle getCascadeStyle() throws MappingException {
	Type type = value.getType();
	if ( type.isComponentType() ) {
		return getCompositeCascadeStyle( (CompositeType) type, cascade );
	}
	else if ( type.isCollectionType() ) {
		return getCollectionCascadeStyle( ( (Collection) value ).getElement().getType(), cascade );
	}
	else {
		return getCascadeStyle( cascade );			
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:13,代码来源:Property.java

示例11: processJoinReturn

import org.hibernate.type.Type; //导入方法依赖的package包/类
private void processJoinReturn(NativeSQLQueryJoinReturn fetchReturn) {
		String alias = fetchReturn.getAlias();
//		if ( alias2Persister.containsKey( alias ) || collectionAliases.contains( alias ) ) {
		if ( alias2Persister.containsKey( alias ) || alias2CollectionPersister.containsKey( alias ) ) {
			// already been processed...
			return;
		}

		String ownerAlias = fetchReturn.getOwnerAlias();

		// Make sure the owner alias is known...
		if ( !alias2Return.containsKey( ownerAlias ) ) {
			throw new HibernateException( "Owner alias [" + ownerAlias + "] is unknown for alias [" + alias + "]" );
		}

		// If this return's alias has not been processed yet, do so b4 further processing of this return
		if ( !alias2Persister.containsKey( ownerAlias ) ) {
			NativeSQLQueryNonScalarReturn ownerReturn = ( NativeSQLQueryNonScalarReturn ) alias2Return.get(ownerAlias);
			processReturn( ownerReturn );
		}

		SQLLoadable ownerPersister = ( SQLLoadable ) alias2Persister.get( ownerAlias );
		Type returnType = ownerPersister.getPropertyType( fetchReturn.getOwnerProperty() );

		if ( returnType.isCollectionType() ) {
			String role = ownerPersister.getEntityName() + '.' + fetchReturn.getOwnerProperty();
			addCollection( role, alias, fetchReturn.getPropertyResultsMap() );
//			collectionOwnerAliases.add( ownerAlias );
		}
		else if ( returnType.isEntityType() ) {
			EntityType eType = ( EntityType ) returnType;
			String returnEntityName = eType.getAssociatedEntityName();
			SQLLoadable persister = getSQLLoadable( returnEntityName );
			addPersister( alias, fetchReturn.getPropertyResultsMap(), persister );
		}

	}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:38,代码来源:SQLQueryReturnProcessor.java

示例12: indicatesCollection

import org.hibernate.type.Type; //导入方法依赖的package包/类
private boolean indicatesCollection(Type type) {
	if ( type.isCollectionType() ) {
		return true;
	}
	else if ( type.isComponentType() ) {
		Type[] subtypes = ( (CompositeType) type ).getSubtypes();
		for ( int i = 0; i < subtypes.length; i++ ) {
			if ( indicatesCollection( subtypes[i] ) ) {
				return true;
			}
		}
	}
	return false;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:EntityMetamodel.java

示例13: addFetch

import org.hibernate.type.Type; //导入方法依赖的package包/类
/**
 * Add a fetch to the profile.
 *
 * @param fetch The fetch to add.
 */
public void addFetch(final Fetch fetch) {
	final String fetchAssociactionRole = fetch.getAssociation().getRole();
	final Type associationType = fetch.getAssociation().getOwner().getPropertyType( fetch.getAssociation().getAssociationPath() );
	if ( associationType.isCollectionType() ) {
		LOG.tracev( "Handling request to add collection fetch [{0}]", fetchAssociactionRole );

		// couple of things for which to account in the case of collection
		// join fetches
		if ( Fetch.Style.JOIN == fetch.getStyle() ) {
			// first, if this is a bag we need to ignore it if we previously
			// processed collection join fetches
			if ( BagType.class.isInstance( associationType ) ) {
				if ( containsJoinFetchedCollection ) {
					LOG.containsJoinFetchedCollection( fetchAssociactionRole );
					// EARLY EXIT!!!
					return;
				}
			}

			// also, in cases where we are asked to add a collection join
			// fetch where we had already added a bag join fetch previously,
			// we need to go back and ignore that previous bag join fetch.
			if ( containsJoinFetchedBag ) {
				// just for safety...
				if ( fetches.remove( bagJoinFetch.getAssociation().getRole() ) != bagJoinFetch ) {
					LOG.unableToRemoveBagJoinFetch();
				}
				bagJoinFetch = null;
				containsJoinFetchedBag = false;
			}

			containsJoinFetchedCollection = true;
		}
	}
	fetches.put( fetchAssociactionRole, fetch );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:42,代码来源:FetchProfile.java

示例14: cascadeAssociation

import org.hibernate.type.Type; //导入方法依赖的package包/类
private void cascadeAssociation(
		final Object parent,
		final Object child,
		final Type type,
		final CascadeStyle style,
		final Object anything,
		final boolean isCascadeDeleteEnabled) {
	if ( type.isEntityType() || type.isAnyType() ) {
		cascadeToOne( parent, child, type, style, anything, isCascadeDeleteEnabled );
	}
	else if ( type.isCollectionType() ) {
		cascadeCollection( parent, child, style, anything, (CollectionType) type );
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:Cascade.java

示例15: evictCachedCollections

import org.hibernate.type.Type; //导入方法依赖的package包/类
private void evictCachedCollections(Type[] types, Serializable id, SessionFactoryImplementor factory)
		throws HibernateException {
	for ( Type type : types ) {
		if ( type.isCollectionType() ) {
			factory.getCache().evictCollection( ( (CollectionType) type ).getRole(), id );
		}
		else if ( type.isComponentType() ) {
			CompositeType actype = (CompositeType) type;
			evictCachedCollections( actype.getSubtypes(), id, factory );
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:13,代码来源:DefaultRefreshEventListener.java


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