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


Java Type.isEntityType方法代码示例

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


在下文中一共展示了Type.isEntityType方法的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: 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

示例3: finishingCollectionIndex

import org.hibernate.type.Type; //导入方法依赖的package包/类
@Override
public void finishingCollectionIndex(CollectionIndexDefinition indexDefinition) {
	final Type indexType = indexDefinition.getType();

	if ( indexType.isAnyType() ) {
		// nothing to do because the index graph was not pushed in #startingCollectionIndex.
	}
	else if ( indexType.isEntityType() || indexType.isComponentType() ) {
		// todo : validate the stack?
		final ExpandingFetchSource fetchSource = popFromStack();
		if ( !CollectionFetchableIndex.class.isInstance( fetchSource ) ) {
			throw new WalkingException(
					"CollectionReference did not return an expected index graph : " +
							indexDefinition.getCollectionDefinition().getCollectionPersister().getRole()
			);
		}
	}

	log.tracef(
			"%s Finished collection index graph : %s",
			StringHelper.repeat( "<<", fetchSourceStack.size() ),
			indexDefinition.getCollectionDefinition().getCollectionPersister().getRole()
	);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:25,代码来源:AbstractLoadPlanBuildingAssociationVisitationStrategy.java

示例4: createUniqueKeyLoader

import org.hibernate.type.Type; //导入方法依赖的package包/类
private EntityLoader createUniqueKeyLoader(
		Type uniqueKeyType,
		String[] columns,
		LoadQueryInfluencers loadQueryInfluencers) {
	if ( uniqueKeyType.isEntityType() ) {
		String className = ( ( EntityType ) uniqueKeyType ).getAssociatedEntityName();
		uniqueKeyType = getFactory().getEntityPersister( className ).getIdentifierType();
	}
	return new EntityLoader(
			this,
			columns,
			uniqueKeyType,
			1,
			LockMode.NONE,
			getFactory(),
			loadQueryInfluencers
	);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:19,代码来源:AbstractEntityPersister.java

示例5: visitCollectionElements

import org.hibernate.type.Type; //导入方法依赖的package包/类
private void visitCollectionElements(CollectionDefinition collectionDefinition) {
	final CollectionElementDefinition elementDefinition = collectionDefinition.getElementDefinition();
	strategy.startingCollectionElements( elementDefinition );

	final Type collectionElementType = elementDefinition.getType();
	if ( collectionElementType.isAnyType() ) {
		visitAnyDefinition( elementDefinition.toAnyMappingDefinition() );
	}
	else if ( collectionElementType.isComponentType() ) {
		visitCompositeDefinition( elementDefinition.toCompositeElementDefinition() );
	}
	else if ( collectionElementType.isEntityType() ) {
		if ( ! collectionDefinition.getCollectionPersister().isOneToMany() ) {
			final QueryableCollection queryableCollection = (QueryableCollection) collectionDefinition.getCollectionPersister();
			addAssociationKey(
					new AssociationKey(
							queryableCollection.getTableName(),
							queryableCollection.getElementColumnNames()
					)
			);
		}
		visitEntityDefinition( elementDefinition.toEntityDefinition() );
	}

	strategy.finishingCollectionElements( elementDefinition );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:27,代码来源:MetamodelGraphWalker.java

示例6: hasAssociation

import org.hibernate.type.Type; //导入方法依赖的package包/类
private boolean hasAssociation(CompositeType componentType) {
	for ( Type subType : componentType.getSubtypes() ) {
		if ( subType.isEntityType() ) {
			return true;
		}
		else if ( subType.isComponentType() && hasAssociation( ( (CompositeType) subType ) ) ) {
			return true;
		}
	}
	return false;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:12,代码来源:EntityJoinWalker.java

示例7: startingCollectionIndex

import org.hibernate.type.Type; //导入方法依赖的package包/类
@Override
public void startingCollectionIndex(CollectionIndexDefinition indexDefinition) {
	final Type indexType = indexDefinition.getType();
	log.tracef(
			"%s Starting collection index graph : %s",
			StringHelper.repeat( ">>", fetchSourceStack.size() ),
			indexDefinition.getCollectionDefinition().getCollectionPersister().getRole()
	);

	final CollectionReference collectionReference = currentCollection();
	final CollectionFetchableIndex indexGraph = collectionReference.getIndexGraph();

	if ( indexType.isEntityType() || indexType.isComponentType() ) {
		if ( indexGraph == null ) {
			throw new WalkingException(
					"CollectionReference did not return an expected index graph : " +
							indexDefinition.getCollectionDefinition().getCollectionPersister().getRole()
			);
		}
		if ( !indexType.isAnyType() ) {
			pushToStack( (ExpandingFetchSource) indexGraph );
		}
	}
	else {
		if ( indexGraph != null ) {
			throw new WalkingException(
					"CollectionReference returned an unexpected index graph : " +
							indexDefinition.getCollectionDefinition().getCollectionPersister().getRole()
			);
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:33,代码来源:AbstractLoadPlanBuildingAssociationVisitationStrategy.java

示例8: setIdentifier

import org.hibernate.type.Type; //导入方法依赖的package包/类
@Override
public void setIdentifier(Object entity, Serializable id, EntityMode entityMode, SessionImplementor session) {
	final Object[] extractedValues = mappedIdentifierType.getPropertyValues( id, entityMode );
	final Object[] injectionValues = new Object[ extractedValues.length ];
	final PersistenceContext persistenceContext = session.getPersistenceContext();
	for ( int i = 0; i < virtualIdComponent.getSubtypes().length; i++ ) {
		final Type virtualPropertyType = virtualIdComponent.getSubtypes()[i];
		final Type idClassPropertyType = mappedIdentifierType.getSubtypes()[i];
		if ( virtualPropertyType.isEntityType() && ! idClassPropertyType.isEntityType() ) {
			if ( session == null ) {
				throw new AssertionError(
						"Deprecated version of getIdentifier (no session) was used but session was required"
				);
			}
			final String associatedEntityName = ( (EntityType) virtualPropertyType ).getAssociatedEntityName();
			final EntityKey entityKey = session.generateEntityKey(
					(Serializable) extractedValues[i],
					session.getFactory().getEntityPersister( associatedEntityName )
			);
			// it is conceivable there is a proxy, so check that first
			Object association = persistenceContext.getProxy( entityKey );
			if ( association == null ) {
				// otherwise look for an initialized version
				association = persistenceContext.getEntity( entityKey );
			}
			injectionValues[i] = association;
		}
		else {
			injectionValues[i] = extractedValues[i];
		}
	}
	virtualIdComponent.setPropertyValues( entity, injectionValues, entityMode );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:34,代码来源:AbstractEntityTuplizer.java

示例9: findBatchNumber

import org.hibernate.type.Type; //导入方法依赖的package包/类
/**
 * Finds an acceptable batch for this entity to be a member as part of the {@link InsertActionSorter}
 * 
 * @param action The action being sorted
 * @param entityName The name of the entity affected by the action
 * @return An appropriate batch number; todo document this process better
 */
private Integer findBatchNumber(AbstractEntityInsertAction action, String entityName) {
	// loop through all the associated entities and make sure they have been
	// processed before the latest
	// batch associated with this entity type.

	// the current batch number is the latest batch for this entity type.
	Integer latestBatchNumberForType = latestBatches.get( entityName );

	// loop through all the associations of the current entity and make sure that they are processed
	// before the current batch number
	Object[] propertyValues = action.getState();
	Type[] propertyTypes = action.getPersister().getClassMetadata().getPropertyTypes();

	for ( int i = 0; i < propertyValues.length; i++ ) {
		Object value = propertyValues[i];
		Type type = propertyTypes[i];
		if ( type.isEntityType() && value != null ) {
			// find the batch number associated with the current association, if any.
			Integer associationBatchNumber = entityBatchNumber.get( value );
			if ( associationBatchNumber != null && associationBatchNumber.compareTo( latestBatchNumberForType ) > 0 ) {
				// create a new batch for this type. The batch number is the number of current batches.
				latestBatchNumberForType = actionBatches.size();
				latestBatches.put( entityName, latestBatchNumberForType );
				// since this entity will now be processed in the latest possible batch,
				// we can be assured that it will come after all other associations,
				// there's not need to continue checking.
				break;
			}
		}
	}
	return latestBatchNumberForType;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:40,代码来源:ActionQueue.java

示例10: noCascade

import org.hibernate.type.Type; //导入方法依赖的package包/类
@Override
public void noCascade(
		EventSource session,
		Object child,
		Object parent,
		EntityPersister persister,
		int propertyIndex) {
	if ( child == null ) {
		return;
	}
	Type type = persister.getPropertyTypes()[propertyIndex];
	if ( type.isEntityType() ) {
		String childEntityName = ((EntityType) type).getAssociatedEntityName( session.getFactory() );

		if ( !isInManagedState( child, session )
				&& !(child instanceof HibernateProxy) //a proxy cannot be transient and it breaks ForeignKeys.isTransient
				&& ForeignKeys.isTransient( childEntityName, child, null, session ) ) {
			String parentEntiytName = persister.getEntityName();
			String propertyName = persister.getPropertyNames()[propertyIndex];
			throw new TransientPropertyValueException(
					"object references an unsaved transient instance - save the transient instance before flushing",
					childEntityName,
					parentEntiytName,
					propertyName
			);

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

示例11: nullifyTransientReferences

import org.hibernate.type.Type; //导入方法依赖的package包/类
/**
 * Return null if the argument is an "unsaved" entity (ie. one with no existing database row), or the
 * input argument otherwise.  This is how Hibernate avoids foreign key constraint violations.
 *
 * @param value An entity attribute value
 * @param type An entity attribute type
 *
 * @return {@code null} if the argument is an unsaved entity; otherwise return the argument.
 */
private Object nullifyTransientReferences(final Object value, final Type type) {
	if ( value == null ) {
		return null;
	}
	else if ( type.isEntityType() ) {
		final EntityType entityType = (EntityType) type;
		if ( entityType.isOneToOne() ) {
			return value;
		}
		else {
			final String entityName = entityType.getAssociatedEntityName();
			return isNullifiable( entityName, value ) ? null : value;
		}
	}
	else if ( type.isAnyType() ) {
		return isNullifiable( null, value ) ? null : value;
	}
	else if ( type.isComponentType() ) {
		final CompositeType actype = (CompositeType) type;
		final Object[] subvalues = actype.getPropertyValues( value, session );
		final Type[] subtypes = actype.getSubtypes();
		boolean substitute = false;
		for ( int i = 0; i < subvalues.length; i++ ) {
			final Object replacement = nullifyTransientReferences( subvalues[i], subtypes[i] );
			if ( replacement != subvalues[i] ) {
				substitute = true;
				subvalues[i] = replacement;
			}
		}
		if ( substitute ) {
			// todo : need to account for entity mode on the CompositeType interface :(
			actype.setPropertyValues( value, subvalues, EntityMode.POJO );
		}
		return value;
	}
	else {
		return value;
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:49,代码来源:ForeignKeys.java

示例12: 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

示例13: createElementJoin

import org.hibernate.type.Type; //导入方法依赖的package包/类
FromElement createElementJoin(QueryableCollection queryableCollection) throws SemanticException {
		FromElement elem;

		implied = true; //TODO: always true for now, but not if we later decide to support elements() in the from clause
		inElementsFunction = true;
		Type elementType = queryableCollection.getElementType();
		if ( !elementType.isEntityType() ) {
			throw new IllegalArgumentException( "Cannot create element join for a collection of non-entities!" );
		}
		this.queryableCollection = queryableCollection;
		SessionFactoryHelper sfh = fromClause.getSessionFactoryHelper();
		FromElement destination = null;
		String tableAlias = null;
		EntityPersister entityPersister = queryableCollection.getElementPersister();
		tableAlias = fromClause.getAliasGenerator().createName( entityPersister.getEntityName() );
		String associatedEntityName = entityPersister.getEntityName();
		EntityPersister targetEntityPersister = sfh.requireClassPersister( associatedEntityName );
		// Create the FROM element for the target (the elements of the collection).
		destination = createAndAddFromElement(
				associatedEntityName,
				classAlias,
				targetEntityPersister,
				(EntityType) queryableCollection.getElementType(),
				tableAlias
		);
		// If the join is implied, then don't include sub-classes on the element.
		if ( implied ) {
			destination.setIncludeSubclasses( false );
		}
		fromClause.addCollectionJoinFromElementByPath( path, destination );
//		origin.addDestination(destination);
		// Add the query spaces.
		fromClause.getWalker().addQuerySpaces( entityPersister.getQuerySpaces() );

		CollectionType type = queryableCollection.getCollectionType();
		String role = type.getRole();
		String roleAlias = origin.getTableAlias();

		String[] targetColumns = sfh.getCollectionElementColumns( role, roleAlias );
		AssociationType elementAssociationType = sfh.getElementAssociationType( type );

		// Create the join element under the from element.
		JoinType joinType = JoinType.INNER_JOIN;
		JoinSequence joinSequence = sfh.createJoinSequence(
				implied,
				elementAssociationType,
				tableAlias,
				joinType,
				targetColumns
		);
		elem = initializeJoin( path, destination, joinSequence, targetColumns, origin, false );
		elem.setUseFromFragment( true );    // The associated entity is implied, but it must be included in the FROM.
		elem.setCollectionTableAlias( roleAlias );    // The collection alias is the role.
		return elem;
	}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:56,代码来源:FromElementFactory.java

示例14: resolve

import org.hibernate.type.Type; //导入方法依赖的package包/类
public void resolve(boolean generateJoin, boolean implicitJoin, String classAlias, AST parent)
		throws SemanticException {
	// If this dot has already been resolved, stop now.
	if ( isResolved() ) {
		return;
	}
	Type propertyType = prepareLhs(); // Prepare the left hand side and get the data type.

	// If there is no data type for this node, and we're at the end of the path (top most dot node), then
	// this might be a Java constant.
	if ( propertyType == null ) {
		if ( parent == null ) {
			getWalker().getLiteralProcessor().lookupConstant( this );
		}
		// If the propertyType is null and there isn't a parent, just
		// stop now... there was a problem resolving the node anyway.
		return;
	}

	if ( propertyType.isComponentType() ) {
		// The property is a component...
		checkLhsIsNotCollection();
		dereferenceComponent( parent );
		initText();
	}
	else if ( propertyType.isEntityType() ) {
		// The property is another class..
		checkLhsIsNotCollection();
		dereferenceEntity( (EntityType) propertyType, implicitJoin, classAlias, generateJoin, parent );
		initText();
	}
	else if ( propertyType.isCollectionType() ) {
		// The property is a collection...
		checkLhsIsNotCollection();
		dereferenceCollection( (CollectionType) propertyType, implicitJoin, false, classAlias, parent );
	}
	else {
		// Otherwise, this is a primitive type.
		if ( !CollectionProperties.isAnyCollectionProperty( propertyName ) ) {
			checkLhsIsNotCollection();
		}
		dereferenceType = DereferenceType.PRIMITIVE;
		initText();
	}
	setResolved();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:47,代码来源:DotNode.java

示例15: prepareFromClauseInputTree

import org.hibernate.type.Type; //导入方法依赖的package包/类
@Override
	protected void prepareFromClauseInputTree(AST fromClauseInput) {
		if ( !isSubQuery() ) {
//			// inject param specifications to account for dynamic filter param values
//			if ( ! getEnabledFilters().isEmpty() ) {
//				Iterator filterItr = getEnabledFilters().values().iterator();
//				while ( filterItr.hasNext() ) {
//					FilterImpl filter = ( FilterImpl ) filterItr.next();
//					if ( ! filter.getFilterDefinition().getParameterNames().isEmpty() ) {
//						Iterator paramItr = filter.getFilterDefinition().getParameterNames().iterator();
//						while ( paramItr.hasNext() ) {
//							String parameterName = ( String ) paramItr.next();
//							// currently param filters *only* work with single-column parameter types;
//							// if that limitation is ever lifted, this logic will need to change to account for that
//							ParameterNode collectionFilterKeyParameter = ( ParameterNode ) astFactory.create( PARAM, "?" );
//							DynamicFilterParameterSpecification paramSpec = new DynamicFilterParameterSpecification(
//									filter.getName(),
//									parameterName,
//									filter.getFilterDefinition().getParameterType( parameterName ),
//									 positionalParameterCount++
//							);
//							collectionFilterKeyParameter.setHqlParameterSpecification( paramSpec );
//							parameters.add( paramSpec );
//						}
//					}
//				}
//			}

			if ( isFilter() ) {
				// Handle collection-filter compilation.
				// IMPORTANT NOTE: This is modifying the INPUT (HQL) tree, not the output tree!
				QueryableCollection persister = sessionFactoryHelper.getCollectionPersister( collectionFilterRole );
				Type collectionElementType = persister.getElementType();
				if ( !collectionElementType.isEntityType() ) {
					throw new QueryException( "collection of values in filter: this" );
				}

				String collectionElementEntityName = persister.getElementPersister().getEntityName();
				ASTFactory inputAstFactory = hqlParser.getASTFactory();
				AST fromElement = inputAstFactory.create( HqlTokenTypes.FILTER_ENTITY, collectionElementEntityName );
				ASTUtil.createSibling( inputAstFactory, HqlTokenTypes.ALIAS, "this", fromElement );
				fromClauseInput.addChild( fromElement );
				// Show the modified AST.
				LOG.debug( "prepareFromClauseInputTree() : Filter - Added 'this' as a from element..." );
				queryTranslatorImpl.showHqlAst( hqlParser.getAST() );

				// Create a parameter specification for the collection filter...
				Type collectionFilterKeyType = sessionFactoryHelper.requireQueryableCollection( collectionFilterRole )
						.getKeyType();
				ParameterNode collectionFilterKeyParameter = (ParameterNode) astFactory.create( PARAM, "?" );
				CollectionFilterKeyParameterSpecification collectionFilterKeyParameterSpec = new CollectionFilterKeyParameterSpecification(
						collectionFilterRole, collectionFilterKeyType, positionalParameterCount++
				);
				collectionFilterKeyParameter.setHqlParameterSpecification( collectionFilterKeyParameterSpec );
				parameters.add( collectionFilterKeyParameterSpec );
			}
		}
	}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:59,代码来源:HqlSqlWalker.java


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