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


Java MappingException类代码示例

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


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

示例1: reassociateIfUninitializedProxy

import org.hibernate.MappingException; //导入依赖的package包/类
@Override
public boolean reassociateIfUninitializedProxy(Object value) throws MappingException {
	if ( value instanceof ElementWrapper ) {
		value = ( (ElementWrapper) value ).getElement();
	}

	if ( !Hibernate.isInitialized( value ) ) {
		final HibernateProxy proxy = (HibernateProxy) value;
		final LazyInitializer li = proxy.getHibernateLazyInitializer();
		reassociateProxy( li, proxy );
		return true;
	}
	else {
		return false;
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:StatefulPersistenceContext.java

示例2: guessType

import org.hibernate.MappingException; //导入依赖的package包/类
private Type guessType(Class clazz) throws HibernateException {
	String typename = clazz.getName();
	Type type = session.getFactory().getTypeResolver().heuristicType(typename);
	boolean serializable = type!=null && type instanceof SerializableType;
	if (type==null || serializable) {
		try {
			session.getFactory().getEntityPersister( clazz.getName() );
		}
		catch (MappingException me) {
			if (serializable) {
				return type;
			}
			else {
				throw new HibernateException("Could not determine a type for class: " + typename);
			}
		}
		return ( (Session) session ).getTypeHelper().entity( clazz );
	}
	else {
		return type;
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:AbstractQueryImpl.java

示例3: parseIdentifierGeneratorRegistration

import org.hibernate.MappingException; //导入依赖的package包/类
private static void parseIdentifierGeneratorRegistration(Element element, Mappings mappings) {
	String strategy = element.attributeValue( "name" );
	if ( StringHelper.isEmpty( strategy ) ) {
		throw new MappingException( "'name' attribute expected for identifier-generator elements" );
	}
	String generatorClassName = element.attributeValue( "class" );
	if ( StringHelper.isEmpty( generatorClassName ) ) {
		throw new MappingException( "'class' attribute expected for identifier-generator [[email protected]=" + strategy + "]" );
	}

	try {
		Class generatorClass = ReflectHelper.classForName( generatorClassName );
		mappings.getIdentifierGeneratorFactory().register( strategy, generatorClass );
	}
	catch ( ClassNotFoundException e ) {
		throw new MappingException( "Unable to locate identifier-generator class [name=" + strategy + ", class=" + generatorClassName + "]" );
	}

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

示例4: setParameterValues

import org.hibernate.MappingException; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public void setParameterValues(Properties parameters) {
	ParameterType reader = (ParameterType) parameters.get( PARAMETER_TYPE );
	if ( reader != null ) {
		setJavaTypeDescriptor( new SerializableTypeDescriptor<T>( reader.getReturnedClass() ) );
	} else {
		String className = parameters.getProperty( CLASS_NAME );
		if ( className == null ) {
			throw new MappingException( "No class name defined for type: " + SerializableToBlobType.class.getName() );
		}
		try {
			setJavaTypeDescriptor( new SerializableTypeDescriptor<T>( ReflectHelper.classForName( className ) ) );
		} catch ( ClassNotFoundException e ) {
			throw new MappingException( "Unable to load class from " + CLASS_NAME + " parameter", e );
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:19,代码来源:SerializableToBlobType.java

示例5: bindOneToMany

import org.hibernate.MappingException; //导入依赖的package包/类
public static void bindOneToMany(Element node, OneToMany oneToMany, Mappings mappings)
		throws MappingException {

	oneToMany.setReferencedEntityName( getEntityName( node, mappings ) );

	String embed = node.attributeValue( "embed-xml" );
	// sometimes embed is set to the default value when not specified in the mapping,
	// so can't seem to determine if an attribute was explicitly set;
	// log a warning if embed has a value different from the default.
	if ( !StringHelper.isEmpty( embed ) &&  !"true".equals( embed ) ) {
		LOG.embedXmlAttributesNoLongerSupported();
	}
	oneToMany.setEmbedded( embed == null || "true".equals( embed ) );

	String notFound = node.attributeValue( "not-found" );
	oneToMany.setIgnoreNotFound( "ignore".equals( notFound ) );

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

示例6: NamedProcedureCallDefinition

import org.hibernate.MappingException; //导入依赖的package包/类
NamedProcedureCallDefinition(NamedStoredProcedureQuery annotation) {
	this.registeredName = annotation.name();
	this.procedureName = annotation.procedureName();
	this.resultClasses = annotation.resultClasses();
	this.resultSetMappings = annotation.resultSetMappings();
	this.parameterDefinitions = new ParameterDefinitions( annotation.parameters() );
	this.hints = new QueryHintDefinition( annotation.hints() ).getHintsMap();

	final boolean specifiesResultClasses = resultClasses != null && resultClasses.length > 0;
	final boolean specifiesResultSetMappings = resultSetMappings != null && resultSetMappings.length > 0;

	if ( specifiesResultClasses && specifiesResultSetMappings ) {
		throw new MappingException(
				String.format(
						"NamedStoredProcedureQuery [%s] specified both resultClasses and resultSetMappings",
						registeredName
				)
		);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:NamedProcedureCallDefinition.java

示例7: addSubclass

import org.hibernate.MappingException; //导入依赖的package包/类
public void addSubclass(Subclass subclass) throws MappingException {
	// inheritance cycle detection (paranoid check)
	PersistentClass superclass = getSuperclass();
	while (superclass!=null) {
		if( subclass.getEntityName().equals( superclass.getEntityName() ) ) {
			throw new MappingException(
				"Circular inheritance mapping detected: " +
				subclass.getEntityName() +
				" will have it self as superclass when extending " +
				getEntityName()
			);
		}
		superclass = superclass.getSuperclass();
	}
	subclasses.add(subclass);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:PersistentClass.java

示例8: checkColumnDuplication

import org.hibernate.MappingException; //导入依赖的package包/类
protected void checkColumnDuplication(Set distinctColumns, Iterator columns) 
throws MappingException {
	while ( columns.hasNext() ) {
		Selectable columnOrFormula = (Selectable) columns.next();
		if ( !columnOrFormula.isFormula() ) {
			Column col = (Column) columnOrFormula;
			if ( !distinctColumns.add( col.getName() ) ) {
				throw new MappingException( 
						"Repeated column in mapping for entity: " +
						getEntityName() +
						" column: " +
						col.getName() + 
						" (should be mapped with insert=\"false\" update=\"false\")"
					);
			}
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:19,代码来源:PersistentClass.java

示例9: parseFetchProfile

import org.hibernate.MappingException; //导入依赖的package包/类
private static void parseFetchProfile(Element element, Mappings mappings, String containingEntityName) {
	String profileName = element.attributeValue( "name" );
	FetchProfile profile = mappings.findOrCreateFetchProfile( profileName, MetadataSource.HBM );
	Iterator itr = element.elementIterator( "fetch" );
	while ( itr.hasNext() ) {
		final Element fetchElement = ( Element ) itr.next();
		final String association = fetchElement.attributeValue( "association" );
		final String style = fetchElement.attributeValue( "style" );
		String entityName = fetchElement.attributeValue( "entity" );
		if ( entityName == null ) {
			entityName = containingEntityName;
		}
		if ( entityName == null ) {
			throw new MappingException( "could not determine entity for fetch-profile fetch [" + profileName + "]:[" + association + "]" );
		}
		profile.addFetch( entityName, association, style );
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:19,代码来源:HbmBinder.java

示例10: determineIdType

import org.hibernate.MappingException; //导入依赖的package包/类
private IdType determineIdType() {
	List<AnnotationInstance> idAnnotations = findIdAnnotations( JPADotNames.ID );
	List<AnnotationInstance> embeddedIdAnnotations = findIdAnnotations( JPADotNames.EMBEDDED_ID );

	if ( !idAnnotations.isEmpty() && !embeddedIdAnnotations.isEmpty() ) {
		throw new MappingException(
				"@EmbeddedId and @Id cannot be used together. Check the configuration for " + getName() + "."
		);
	}

	if ( !embeddedIdAnnotations.isEmpty() ) {
		if ( embeddedIdAnnotations.size() == 1 ) {
			return IdType.EMBEDDED;
		}
		else {
			throw new AnnotationException( "Multiple @EmbeddedId annotations are not allowed" );
		}
	}

	if ( !idAnnotations.isEmpty() ) {
		return idAnnotations.size() == 1 ? IdType.SIMPLE : IdType.COMPOSED;
	}
	return IdType.NONE;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:25,代码来源:EntityClass.java

示例11: OneToManyJoinWalker

import org.hibernate.MappingException; //导入依赖的package包/类
public OneToManyJoinWalker(
		QueryableCollection oneToManyPersister,
		int batchSize,
		String subquery,
		SessionFactoryImplementor factory,
		LoadQueryInfluencers loadQueryInfluencers) throws MappingException {
	super( factory, loadQueryInfluencers );

	this.oneToManyPersister = oneToManyPersister;

	final OuterJoinLoadable elementPersister = (OuterJoinLoadable) oneToManyPersister.getElementPersister();
	final String alias = generateRootAlias( oneToManyPersister.getRole() );

	walkEntityTree(elementPersister, alias);

	List allAssociations = new ArrayList();
	allAssociations.addAll(associations);
	allAssociations.add( OuterJoinableAssociation.createRoot( oneToManyPersister.getCollectionType(), alias, getFactory() ) );
	initPersisters(allAssociations, LockMode.NONE);
	initStatementString(elementPersister, alias, batchSize, subquery);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:OneToManyJoinWalker.java

示例12: initIdentifierPropertyPaths

import org.hibernate.MappingException; //导入依赖的package包/类
protected void initIdentifierPropertyPaths(
		final String path,
		final EntityType etype,
		final String[] columns,
		final String[] columnReaders,
		final String[] columnReaderTemplates,
		final Mapping factory) throws MappingException {

	Type idtype = etype.getIdentifierOrUniqueKeyType( factory );
	String idPropName = etype.getIdentifierOrUniqueKeyPropertyName(factory);
	boolean hasNonIdentifierPropertyNamedId = hasNonIdentifierPropertyNamedId( etype, factory );

	if ( etype.isReferenceToPrimaryKey() ) {
		if ( !hasNonIdentifierPropertyNamedId ) {
			String idpath1 = extendPath(path, EntityPersister.ENTITY_ID);
			addPropertyPath(idpath1, idtype, columns, columnReaders, columnReaderTemplates, null);
			initPropertyPaths(idpath1, idtype, columns, columnReaders, columnReaderTemplates, null, factory);
		}
	}

	if (idPropName!=null) {
		String idpath2 = extendPath(path, idPropName);
		addPropertyPath(idpath2, idtype, columns, columnReaders, columnReaderTemplates, null);
		initPropertyPaths(idpath2, idtype, columns, columnReaders, columnReaderTemplates, null, factory);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:27,代码来源:AbstractPropertyMapping.java

示例13: isJoinedFetchEnabledInMapping

import org.hibernate.MappingException; //导入依赖的package包/类
/**
 * Does the mapping, and Hibernate default semantics, specify that
 * this association should be fetched by outer joining
 */
protected boolean isJoinedFetchEnabledInMapping(FetchMode config, AssociationType type) 
throws MappingException {
	if ( !type.isEntityType() && !type.isCollectionType() ) {
		return false;
	}
	else {
		if (config==FetchMode.JOIN) return true;
		if (config==FetchMode.SELECT) return false;
		if ( type.isEntityType() ) {
			//TODO: look at the owning property and check that it 
			//      isn't lazy (by instrumentation)
			EntityType entityType =(EntityType) type;
			EntityPersister persister = getFactory().getEntityPersister( entityType.getAssociatedEntityName() );
			return !persister.hasProxy();
		}
		else {
			return false;
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:25,代码来源:JoinWalker.java

示例14: getDefaultAccess

import org.hibernate.MappingException; //导入依赖的package包/类
public AccessType getDefaultAccess() throws MappingException {
	AccessType accessType = defaultAccess;

	AccessType hibernateAccessType = AccessType.DEFAULT;
	AccessType jpaAccessType = AccessType.DEFAULT;

	org.hibernate.annotations.AccessType accessTypeAnnotation = property.getAnnotation( org.hibernate.annotations.AccessType.class );
	if ( accessTypeAnnotation != null ) {
		hibernateAccessType = AccessType.getAccessStrategy( accessTypeAnnotation.value() );
	}

	Access access = property.getAnnotation( Access.class );
	if ( access != null ) {
		jpaAccessType = AccessType.getAccessStrategy( access.value() );
	}

	if ( hibernateAccessType != AccessType.DEFAULT
			&& jpaAccessType != AccessType.DEFAULT
			&& hibernateAccessType != jpaAccessType ) {

		StringBuilder builder = new StringBuilder();
		builder.append( property.toString() );
		builder.append(
				" defines @AccessType and @Access with contradicting values. Use of @Access only is recommended."
		);
		throw new MappingException( builder.toString() );
	}

	if ( hibernateAccessType != AccessType.DEFAULT ) {
		accessType = hibernateAccessType;
	}
	else if ( jpaAccessType != AccessType.DEFAULT ) {
		accessType = jpaAccessType;
	}
	return accessType;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:37,代码来源:PropertyInferredData.java

示例15: initDiscriminatorPropertyPath

import org.hibernate.MappingException; //导入依赖的package包/类
private void initDiscriminatorPropertyPath(Mapping mapping) throws MappingException {
	propertyMapping.initPropertyPaths( ENTITY_CLASS,
			getDiscriminatorType(),
			new String[]{getDiscriminatorColumnName()},
			new String[]{getDiscriminatorColumnReaders()},
			new String[]{getDiscriminatorColumnReaderTemplate()},
			new String[]{getDiscriminatorFormulaTemplate()},
			getFactory() );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:AbstractEntityPersister.java


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