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


Java AssertionFailure类代码示例

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


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


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