• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java AssertionFailure类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.hibernate.AssertionFailure的典型用法代码示例。如果您正苦于以下问题:Java AssertionFailure类的具体用法?Java AssertionFailure怎么用?Java AssertionFailure使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: addAttributeConverter

import org.hibernate.AssertionFailure; //导入依赖的package包/类
public void addAttributeConverter(AttributeConverterDefinition definition) {
	if ( attributeConverterDefinitionsByClass == null ) {
		attributeConverterDefinitionsByClass = new ConcurrentHashMap<Class, AttributeConverterDefinition>();
	}

	final Object old = attributeConverterDefinitionsByClass.put( definition.getAttributeConverter().getClass(), definition );

	if ( old != null ) {
		throw new AssertionFailure(
				String.format(
						"AttributeConverter class [%s] registered multiple times",
						definition.getAttributeConverter().getClass()
				)
		);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:Configuration.java


示例2: doSecondPass

import org.hibernate.AssertionFailure; //导入依赖的package包/类
public void doSecondPass(java.util.Map persistentClasses) throws MappingException {
	if ( value instanceof ManyToOne ) {
		ManyToOne manyToOne = (ManyToOne) value;
		PersistentClass ref = (PersistentClass) persistentClasses.get( manyToOne.getReferencedEntityName() );
		if ( ref == null ) {
			throw new AnnotationException(
					"@OneToOne or @ManyToOne on "
							+ StringHelper.qualify( entityClassName, path )
							+ " references an unknown entity: "
							+ manyToOne.getReferencedEntityName()
			);
		}
		BinderHelper.createSyntheticPropertyReference( columns, ref, null, manyToOne, false, mappings );
		TableBinder.bindFk( ref, null, columns, manyToOne, unique, mappings );
		/*
		 * HbmMetadataSourceProcessorImpl does this only when property-ref != null, but IMO, it makes sense event if it is null
		 */
		if ( !manyToOne.isIgnoreNotFound() ) manyToOne.createPropertyRefConstraints( persistentClasses );
	}
	else if ( value instanceof OneToOne ) {
		value.createForeignKey();
	}
	else {
		throw new AssertionFailure( "FkSecondPass for a wrong value type: " + value.getClass().getName() );
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:27,代码来源:ToOneFkSecondPass.java


示例3: getMappedSuperclassOrNull

import org.hibernate.AssertionFailure; //导入依赖的package包/类
public static MappedSuperclass getMappedSuperclassOrNull(
		XClass declaringClass,
		Map<XClass, InheritanceState> inheritanceStatePerClass,
		Mappings mappings) {
	boolean retrieve = false;
	if ( declaringClass != null ) {
		final InheritanceState inheritanceState = inheritanceStatePerClass.get( declaringClass );
		if ( inheritanceState == null ) {
			throw new org.hibernate.annotations.common.AssertionFailure(
					"Declaring class is not found in the inheritance state hierarchy: " + declaringClass
			);
		}
		if ( inheritanceState.isEmbeddableSuperclass() ) {
			retrieve = true;
		}
	}
	return retrieve ?
			mappings.getMappedSuperclass( mappings.getReflectionManager().toClass( declaringClass ) ) :
	        null;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:BinderHelper.java


示例4: getSuperEntity

import org.hibernate.AssertionFailure; //导入依赖的package包/类
private static PersistentClass getSuperEntity(XClass clazzToProcess, Map<XClass, InheritanceState> inheritanceStatePerClass, Mappings mappings, InheritanceState inheritanceState) {
	InheritanceState superEntityState = InheritanceState.getInheritanceStateOfSuperEntity(
			clazzToProcess, inheritanceStatePerClass
	);
	PersistentClass superEntity = superEntityState != null ?
			mappings.getClass(
					superEntityState.getClazz().getName()
			) :
			null;
	if ( superEntity == null ) {
		//check if superclass is not a potential persistent class
		if ( inheritanceState.hasParents() ) {
			throw new AssertionFailure(
					"Subclass has to be binded after it's mother class: "
							+ superEntityState.getClazz().getName()
			);
		}
	}
	return superEntity;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:AnnotationBinder.java


示例5: bindDiscriminatorColumnToRootPersistentClass

import org.hibernate.AssertionFailure; //导入依赖的package包/类
private static void bindDiscriminatorColumnToRootPersistentClass(
		RootClass rootClass,
		Ejb3DiscriminatorColumn discriminatorColumn,
		Map<String, Join> secondaryTables,
		PropertyHolder propertyHolder,
		Mappings mappings) {
	if ( rootClass.getDiscriminator() == null ) {
		if ( discriminatorColumn == null ) {
			throw new AssertionFailure( "discriminator column should have been built" );
		}
		discriminatorColumn.setJoins( secondaryTables );
		discriminatorColumn.setPropertyHolder( propertyHolder );
		SimpleValue discriminatorColumnBinding = new SimpleValue( mappings, rootClass.getTable() );
		rootClass.setDiscriminator( discriminatorColumnBinding );
		discriminatorColumn.linkWithValue( discriminatorColumnBinding );
		discriminatorColumnBinding.setTypeName( discriminatorColumn.getDiscriminatorTypeName() );
		rootClass.setPolymorphic( true );
		if ( LOG.isTraceEnabled() ) {
			LOG.tracev( "Setting discriminator for entity {0}", rootClass.getEntityName() );
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:AnnotationBinder.java


示例6: CollectionRemoveAction

import org.hibernate.AssertionFailure; //导入依赖的package包/类
/**
 * Removes a persistent collection from its loaded owner.
 *
 * Use this constructor when the collection is non-null.
 *
 * @param collection The collection to to remove; must be non-null
 * @param persister  The collection's persister
 * @param id The collection key
 * @param emptySnapshot Indicates if the snapshot is empty
 * @param session The session
 *
 * @throws AssertionFailure if collection is null.
 */
public CollectionRemoveAction(
			final PersistentCollection collection,
			final CollectionPersister persister,
			final Serializable id,
			final boolean emptySnapshot,
			final SessionImplementor session) {
	super( persister, collection, id, session );
	if ( collection == null ) {
		throw new AssertionFailure("collection == null");
	}
	this.emptySnapshot = emptySnapshot;
	// the loaded owner will be set to null after the collection is removed,
	// so capture its value as the affected owner so it is accessible to
	// both pre- and post- events
	this.affectedOwner = session.getPersistenceContext().getLoadedCollectionOwnerOrNull( collection );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:30,代码来源:CollectionRemoveAction.java


示例7: getCacheMode

import org.hibernate.AssertionFailure; //导入依赖的package包/类
private static CacheMode getCacheMode(CacheModeType cacheModeType) {
	switch ( cacheModeType ) {
		case GET:
			return CacheMode.GET;
		case IGNORE:
			return CacheMode.IGNORE;
		case NORMAL:
			return CacheMode.NORMAL;
		case PUT:
			return CacheMode.PUT;
		case REFRESH:
			return CacheMode.REFRESH;
		default:
			throw new AssertionFailure( "Unknown cacheModeType: " + cacheModeType );
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:QueryBinder.java


示例8: locateTable

import org.hibernate.AssertionFailure; //导入依赖的package包/类
public TableSpecification locateTable(String tableName) {
    if ( tableName == null || tableName.equals( getPrimaryTableName() ) ) {
        return primaryTable;
    }
    TableSpecification tableSpec = secondaryTables.get( tableName );
    if ( tableSpec == null ) {
        throw new AssertionFailure(
                String.format(
                        "Unable to find table %s amongst tables %s",
                        tableName,
                        secondaryTables.keySet()
                )
        );
    }
    return tableSpec;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:EntityBinding.java


示例9: extractNaturalIdValues

import org.hibernate.AssertionFailure; //导入依赖的package包/类
@Override
public Object[] extractNaturalIdValues(Object entity, EntityPersister persister) {
	if ( entity == null ) {
		throw new AssertionFailure( "Entity from which to extract natural id value(s) cannot be null" );
	}
	if ( persister == null ) {
		throw new AssertionFailure( "Persister to use in extracting natural id value(s) cannot be null" );
	}

	final int[] naturalIdentifierProperties = persister.getNaturalIdentifierProperties();
	final Object[] naturalIdValues = new Object[naturalIdentifierProperties.length];

	for ( int i = 0; i < naturalIdentifierProperties.length; i++ ) {
		naturalIdValues[i] = persister.getPropertyValue( entity, naturalIdentifierProperties[i] );
	}

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


示例10: createBasicEntityBinding

import org.hibernate.AssertionFailure; //导入依赖的package包/类
private EntityBinding createBasicEntityBinding(EntitySource entitySource, EntityBinding superEntityBinding) {
	if ( superEntityBinding == null ) {
		return makeRootEntityBinding( (RootEntitySource) entitySource );
	}
	else {
		switch ( currentInheritanceType ) {
			case SINGLE_TABLE:
				return makeDiscriminatedSubclassBinding( (SubclassEntitySource) entitySource, superEntityBinding );
			case JOINED:
				return makeJoinedSubclassBinding( (SubclassEntitySource) entitySource, superEntityBinding );
			case TABLE_PER_CLASS:
				return makeUnionedSubclassBinding( (SubclassEntitySource) entitySource, superEntityBinding );
			default:
				// extreme internal error!
				throw new AssertionFailure( "Internal condition failure" );
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:19,代码来源:Binder.java


示例11: resolve

import org.hibernate.AssertionFailure; //导入依赖的package包/类
void resolve() {
	for ( EntityBinding entityBinding : metadata.getEntityBindings() ) {
		if ( entityBinding.getHierarchyDetails().getEntityDiscriminator() != null ) {
			resolveDiscriminatorTypeInformation( entityBinding.getHierarchyDetails().getEntityDiscriminator() );
		}
		for ( AttributeBinding attributeBinding : entityBinding.attributeBindings() ) {
			if ( SingularAttributeBinding.class.isInstance( attributeBinding ) ) {
				resolveSingularAttributeTypeInformation(
						SingularAttributeBinding.class.cast( attributeBinding  )
				);
			}
			else if ( AbstractPluralAttributeBinding.class.isInstance( attributeBinding ) ) {
				resolvePluralAttributeTypeInformation(
						AbstractPluralAttributeBinding.class.cast( attributeBinding )
				);
			}
			else {
				throw new AssertionFailure( "Unknown type of AttributeBinding: " + attributeBinding.getClass().getName() );
			}
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:HibernateTypeResolver.java


示例12: resolveSingularAttributeTypeInformation

import org.hibernate.AssertionFailure; //导入依赖的package包/类
private void resolveSingularAttributeTypeInformation(SingularAttributeBinding attributeBinding) {
	if ( attributeBinding.getHibernateTypeDescriptor().getResolvedTypeMapping() != null ) {
		return;
	}
	// we can determine the Hibernate Type if either:
	// 		1) the user explicitly named a Type in a HibernateTypeDescriptor
	// 		2) we know the java type of the attribute
	Type resolvedType;
	resolvedType = determineSingularTypeFromDescriptor( attributeBinding.getHibernateTypeDescriptor() );
	if ( resolvedType == null ) {
		if ( ! attributeBinding.getAttribute().isSingular() ) {
			throw new AssertionFailure( "SingularAttributeBinding object has a plural attribute: " + attributeBinding.getAttribute().getName() );
		}
		final SingularAttribute singularAttribute = ( SingularAttribute ) attributeBinding.getAttribute();
		if ( singularAttribute.getSingularAttributeType() != null ) {
			resolvedType = getHeuristicType(
					singularAttribute.getSingularAttributeType().getClassName(), new Properties()
			);
		}
	}
	if ( resolvedType != null ) {
		pushHibernateTypeInformationDownIfNeeded( attributeBinding, resolvedType );
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:25,代码来源:HibernateTypeResolver.java


示例13: getIdentifierSource

import org.hibernate.AssertionFailure; //导入依赖的package包/类
@Override
public IdentifierSource getIdentifierSource() {
	IdType idType = getEntityClass().getIdType();
	switch ( idType ) {
		case SIMPLE: {
			BasicAttribute attribute = getEntityClass().getIdAttributes().iterator().next();
			return new SimpleIdentifierSourceImpl( attribute, getEntityClass().getAttributeOverrideMap() );
		}
		case COMPOSED: {
			throw new NotYetImplementedException( "Composed ids must still be implemented." );
		}
		case EMBEDDED: {
			throw new NotYetImplementedException( "Embedded ids must still be implemented." );
		}
		default: {
			throw new AssertionFailure( "The root entity needs to specify an identifier" );
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:RootEntitySourceImpl.java


示例14: AttributeOverride

import org.hibernate.AssertionFailure; //导入依赖的package包/类
public AttributeOverride(String prefix, AnnotationInstance attributeOverrideAnnotation) {
	if ( attributeOverrideAnnotation == null ) {
		throw new IllegalArgumentException( "An AnnotationInstance needs to be passed" );
	}

	if ( !JPADotNames.ATTRIBUTE_OVERRIDE.equals( attributeOverrideAnnotation.name() ) ) {
		throw new AssertionFailure( "A @AttributeOverride annotation needs to be passed to the constructor" );
	}

	columnValues = new ColumnValues(
			JandexHelper.getValue(
					attributeOverrideAnnotation,
					"column",
					AnnotationInstance.class
			)
	);
	attributePath = createAttributePath(
			prefix,
			JandexHelper.getValue( attributeOverrideAnnotation, "name", String.class )
	);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:AttributeOverride.java


示例15: afterTransactionCompletion

import org.hibernate.AssertionFailure; //导入依赖的package包/类
public void afterTransactionCompletion(boolean success) {
	while ( !processes.isEmpty() ) {
		try {
			processes.poll().doAfterTransactionCompletion( success, session );
		}
		catch (CacheException ce) {
			LOG.unableToReleaseCacheLock( ce );
			// continue loop
		}
		catch (Exception e) {
			throw new AssertionFailure( "Exception releasing cache locks", e );
		}
	}

	if ( session.getFactory().getSettings().isQueryCacheEnabled() ) {
		session.getFactory().getUpdateTimestampsCache().invalidate(
				querySpacesToInvalidate.toArray( new String[querySpacesToInvalidate.size()] ),
				session
		);
	}
	querySpacesToInvalidate.clear();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:ActionQueue.java


示例16: resolveHibernateTypeParameters

import org.hibernate.AssertionFailure; //导入依赖的package包/类
@Override
protected Map<String, String> resolveHibernateTypeParameters(AnnotationInstance annotationInstance) {
	HashMap<String, String> typeParameters = new HashMap<String, String>();
	typeParameters.put( EnumType.ENUM, mappedAttribute.getAttributeType().getName() );
	if ( annotationInstance != null ) {
		javax.persistence.EnumType enumType = JandexHelper.getEnumValue(
				annotationInstance,
				"value",
				javax.persistence.EnumType.class
		);
		if ( javax.persistence.EnumType.ORDINAL.equals( enumType ) ) {
			typeParameters.put( EnumType.TYPE, String.valueOf( Types.INTEGER ) );
		}
		else if ( javax.persistence.EnumType.STRING.equals( enumType ) ) {
			typeParameters.put( EnumType.TYPE, String.valueOf( Types.VARCHAR ) );
		}
		else {
			throw new AssertionFailure( "Unknown EnumType: " + enumType );
		}
	}
	else {
		typeParameters.put( EnumType.TYPE, String.valueOf( Types.INTEGER ) );
	}
	return typeParameters;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:26,代码来源:EnumeratedTypeResolver.java


示例17: entityCopyDetected

import org.hibernate.AssertionFailure; //导入依赖的package包/类
@Override
public void entityCopyDetected(
		Object managedEntity,
		Object mergeEntity1,
		Object mergeEntity2,
		EventSource session) {
	if ( mergeEntity1 == managedEntity && mergeEntity2 == managedEntity) {
		throw new AssertionFailure( "entity1 and entity2 are the same as managedEntity; must be different." );
	}
	final String managedEntityString = 	MessageHelper.infoString(
			session.getEntityName( managedEntity ),
			session.getIdentifier( managedEntity )
	);
	throw new IllegalStateException(
			"Multiple representations of the same entity " + managedEntityString + " are being merged. " +
					getManagedOrDetachedEntityString( managedEntity, mergeEntity1 ) + "; " +
					getManagedOrDetachedEntityString( managedEntity, mergeEntity2 )
	);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:EntityCopyNotAllowedObserver.java


示例18: EnumState

import org.hibernate.AssertionFailure; //导入依赖的package包/类
private EnumState(int offset, Class<E> enumType) {
	E[] enumConstants = enumType.getEnumConstants();

	// In case any of the enums cannot be stored in 4 bits anymore, we'd have to re-structure the compressed
	// state int
	if ( enumConstants.length > 15 ) {
		throw new AssertionFailure( "Cannot store enum type " + enumType.getName() + " in compressed state as"
				+ " it has too many values." );
	}

	this.offset = offset;
	this.enumConstants = enumConstants;

	// a mask for reading the four bits, starting at the right offset
	this.mask = 0xF << offset;

	// a mask for setting the four bits at the right offset to 0
	this.unsetMask = 0xFFFF & ~mask;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:EntityEntry.java


示例19: getSingleAnnotation

import org.hibernate.AssertionFailure; //导入依赖的package包/类
/**
 * @param annotations List of annotation instances keyed against their dot name.
 * @param annotationName the annotation to retrieve from map
 *
 * @return the single annotation of the specified dot name or {@code null} in case the annotation is not specified at all
 *
 * @throws org.hibernate.AssertionFailure in case there is there is more than one annotation of this type.
 */
public static AnnotationInstance getSingleAnnotation(Map<DotName, List<AnnotationInstance>> annotations, DotName annotationName)
		throws AssertionFailure {
	List<AnnotationInstance> annotationList = annotations.get( annotationName );
	if ( annotationList == null ) {
		return null;
	}
	else if ( annotationList.size() == 1 ) {
		return annotationList.get( 0 );
	}
	else {
		throw new AssertionFailure(
				"Found more than one instance of the annotation "
						+ annotationList.get( 0 ).name().toString()
						+ ". Expected was one."
		);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:26,代码来源:JandexHelper.java


示例20: generationTypeToGeneratorStrategyName

import org.hibernate.AssertionFailure; //导入依赖的package包/类
public static String generationTypeToGeneratorStrategyName(GenerationType generatorEnum, boolean useNewGeneratorMappings) {
	switch ( generatorEnum ) {
		case IDENTITY:
			return "identity";
		case AUTO:
			return useNewGeneratorMappings
					? "enhanced-sequence"
					: "native";
		case TABLE:
			return useNewGeneratorMappings
					? "enhanced-table"
					: MultipleHiLoPerTableGenerator.class.getName();
		case SEQUENCE:
			return useNewGeneratorMappings
					? "enhanced-sequence"
					: "seqhilo";
	}
	throw new AssertionFailure( "Unknown GeneratorType: " + generatorEnum );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:EnumConversionHelper.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SimpleValue类代码示例发布时间:2022-05-23
下一篇:
Java Clock类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap