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


Java PersistentClass类代码示例

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


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

示例1: init

import org.hibernate.mapping.PersistentClass; //导入依赖的package包/类
@PostConstruct
public void init() throws ClassNotFoundException
{
  final Configuration configuration = annotationSessionFactory
        .getConfiguration();
  final ReflectionManager reflectionManager = configuration
        .getReflectionManager();
  final Iterator<PersistentClass> classMappings = configuration
        .getClassMappings();
  while (classMappings.hasNext()) 
  {
     entityCallbackHandler.add(reflectionManager.classForName(
        classMappings.next().getClassName(), this.getClass()),
        reflectionManager);
  }
}
 
开发者ID:SentinelDataHub,项目名称:dhus-core,代码行数:17,代码来源:EntityCallbackHandlerInitializer.java

示例2: bindPojoRepresentation

import org.hibernate.mapping.PersistentClass; //导入依赖的package包/类
private static void bindPojoRepresentation(Element node, PersistentClass entity,
		Mappings mappings, java.util.Map metaTags) {

	String className = getClassName( node.attribute( "name" ), mappings );
	String proxyName = getClassName( node.attribute( "proxy" ), mappings );

	entity.setClassName( className );

	if ( proxyName != null ) {
		entity.setProxyInterfaceName( proxyName );
		entity.setLazy( true );
	}
	else if ( entity.isLazy() ) {
		entity.setProxyInterfaceName( className );
	}

	Element tuplizer = locateTuplizerDefinition( node, EntityMode.POJO );
	if ( tuplizer != null ) {
		entity.addTuplizer( EntityMode.POJO, tuplizer.attributeValue( "class" ) );
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:HbmBinder.java

示例3: getClassTableName

import org.hibernate.mapping.PersistentClass; //导入依赖的package包/类
private static String getClassTableName(
		PersistentClass model,
		Element node,
		String schema,
		String catalog,
		Table denormalizedSuperTable,
		Mappings mappings) {
	Attribute tableNameNode = node.attribute( "table" );
	String logicalTableName;
	String physicalTableName;
	if ( tableNameNode == null ) {
		logicalTableName = StringHelper.unqualify( model.getEntityName() );
		physicalTableName = getNamingStrategyDelegate( mappings ).determineImplicitPrimaryTableName(
				model.getEntityName(),
				model.getJpaEntityName()
		);
	}
	else {
		logicalTableName = tableNameNode.getValue();
		physicalTableName = getNamingStrategyDelegate( mappings ).toPhysicalTableName( logicalTableName );
	}
	mappings.addTableBinding( schema, catalog, logicalTableName, physicalTableName, denormalizedSuperTable );
	return physicalTableName;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:25,代码来源:HbmBinder.java

示例4: doSecondPass

import org.hibernate.mapping.PersistentClass; //导入依赖的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

示例5: doSecondPass

import org.hibernate.mapping.PersistentClass; //导入依赖的package包/类
public void doSecondPass(Map persistentClasses) throws MappingException {
	org.hibernate.mapping.FetchProfile profile = mappings.findOrCreateFetchProfile(
			fetchProfileName,
			MetadataSource.ANNOTATIONS
	);
	if ( MetadataSource.ANNOTATIONS != profile.getSource() ) {
		return;
	}

	PersistentClass clazz = mappings.getClass( fetch.entity().getName() );
	// throws MappingException in case the property does not exist
	clazz.getProperty( fetch.association() );

	profile.addFetch(
			fetch.entity().getName(), fetch.association(), fetch.mode().toString().toLowerCase()
	);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:VerifyFetchProfileReferenceSecondPass.java

示例6: bindReturn

import org.hibernate.mapping.PersistentClass; //导入依赖的package包/类
private static NativeSQLQueryRootReturn bindReturn(Element returnElem, Mappings mappings, int elementCount) {
	String alias = returnElem.attributeValue( "alias" );
	if( StringHelper.isEmpty( alias )) {
		alias = "alias_" + elementCount; // hack/workaround as sqlquery impl depend on having a key.
	}

	String entityName = HbmBinder.getEntityName(returnElem, mappings);
	if(entityName==null) {
		throw new MappingException( "<return alias='" + alias + "'> must specify either a class or entity-name");
	}
	LockMode lockMode = getLockMode( returnElem.attributeValue( "lock-mode" ) );

	PersistentClass pc = mappings.getClass( entityName );
	java.util.Map propertyResults = bindPropertyResults(alias, returnElem, pc, mappings );

	return new NativeSQLQueryRootReturn(
			alias,
			entityName,
			propertyResults,
			lockMode
		);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:ResultSetMappingBinder.java

示例7: processIdPropertiesIfNotAlready

import org.hibernate.mapping.PersistentClass; //导入依赖的package包/类
private static void processIdPropertiesIfNotAlready(
		Map<XClass, InheritanceState> inheritanceStatePerClass,
		Mappings mappings,
		PersistentClass persistentClass,
		EntityBinder entityBinder,
		PropertyHolder propertyHolder,
		HashMap<String, IdGenerator> classGenerators,
		InheritanceState.ElementsToProcess elementsToProcess,
		boolean subclassAndSingleTableStrategy,
		Set<String> idPropertiesIfIdClass) {
	Set<String> missingIdProperties = new HashSet<String>( idPropertiesIfIdClass );
	for ( PropertyData propertyAnnotatedElement : elementsToProcess.getElements() ) {
		String propertyName = propertyAnnotatedElement.getPropertyName();
		if ( !idPropertiesIfIdClass.contains( propertyName ) ) {
			processElementAnnotations(
					propertyHolder,
					subclassAndSingleTableStrategy ?
							Nullability.FORCED_NULL :
							Nullability.NO_CONSTRAINT,
					propertyAnnotatedElement, classGenerators, entityBinder,
					false, false, false, mappings, inheritanceStatePerClass
			);
		}
		else {
			missingIdProperties.remove( propertyName );
		}
	}

	if ( missingIdProperties.size() != 0 ) {
		StringBuilder missings = new StringBuilder();
		for ( String property : missingIdProperties ) {
			missings.append( property ).append( ", " );
		}
		throw new AnnotationException(
				"Unable to find properties ("
						+ missings.substring( 0, missings.length() - 2 )
						+ ") in entity annotated with @IdClass:" + persistentClass.getEntityName()
		);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:41,代码来源:AnnotationBinder.java

示例8: getSuperEntity

import org.hibernate.mapping.PersistentClass; //导入依赖的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

示例9: linkValueUsingDefaultColumnNaming

import org.hibernate.mapping.PersistentClass; //导入依赖的package包/类
public void linkValueUsingDefaultColumnNaming(
		Column referencedColumn,
		PersistentClass referencedEntity,
		SimpleValue value) {
	String columnName;
	String logicalReferencedColumn = getMappings().getLogicalColumnName(
			referencedColumn.getQuotedName(), referencedEntity.getTable()
	);
	columnName = buildDefaultColumnName( referencedEntity, logicalReferencedColumn );
	//yuk side effect on an implicit column
	setLogicalColumnName( columnName );
	setReferencedColumn( logicalReferencedColumn );
	initMappingColumn(
			columnName,
			null, referencedColumn.getLength(),
			referencedColumn.getPrecision(),
			referencedColumn.getScale(),
			getMappingColumn() != null ? getMappingColumn().isNullable() : false,
			referencedColumn.getSqlType(),
			getMappingColumn() != null ? getMappingColumn().isUnique() : false,
		    false
	);
	linkWithValue( value );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:25,代码来源:Ejb3JoinColumn.java

示例10: linkJoinColumnWithValueOverridingNameIfImplicit

import org.hibernate.mapping.PersistentClass; //导入依赖的package包/类
public static void linkJoinColumnWithValueOverridingNameIfImplicit(
		PersistentClass referencedEntity,
		Iterator columnIterator,
		Ejb3JoinColumn[] columns,
		SimpleValue value) {
	for (Ejb3JoinColumn joinCol : columns) {
		Column synthCol = (Column) columnIterator.next();
		if ( joinCol.isNameDeferred() ) {
			//this has to be the default value
			joinCol.linkValueUsingDefaultColumnNaming( synthCol, referencedEntity, value );
		}
		else {
			joinCol.linkWithValue( value );
			joinCol.overrideFromReferencedColumnIfNecessary( synthCol );
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:TableBinder.java

示例11: processPersistentClassHierarchy

import org.hibernate.mapping.PersistentClass; //导入依赖的package包/类
private Set<String> processPersistentClassHierarchy(
		PersistentClass persistentClass,
		boolean isBase,
		SessionFactoryImplementor factory,
		String[][] mapping) {

	// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// collect all the class names that indicate that the "main table" of the given PersistentClass should be
	// included when one of the collected class names is used in TREAT
	final Set<String> classNames = new HashSet<String>();

	final Iterator itr = persistentClass.getDirectSubclasses();
	while ( itr.hasNext() ) {
		final Subclass subclass = (Subclass) itr.next();
		final Set<String> subclassSubclassNames = processPersistentClassHierarchy(
				subclass,
				false,
				factory,
				mapping
		);
		classNames.addAll( subclassSubclassNames );
	}

	classNames.add( persistentClass.getEntityName() );

	if ( ! isBase ) {
		MappedSuperclass msc = persistentClass.getSuperMappedSuperclass();
		while ( msc != null ) {
			classNames.add( msc.getMappedClass().getName() );
			msc = msc.getSuperMappedSuperclass();
		}

		associateSubclassNamesToSubclassTableIndexes( persistentClass, classNames, mapping, factory );
	}

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

示例12: associateSubclassNamesToSubclassTableIndexes

import org.hibernate.mapping.PersistentClass; //导入依赖的package包/类
private void associateSubclassNamesToSubclassTableIndexes(
		PersistentClass persistentClass,
		Set<String> classNames,
		String[][] mapping,
		SessionFactoryImplementor factory) {

	final String tableName = persistentClass.getTable().getQualifiedName(
			factory.getDialect(),
			factory.getSettings().getDefaultCatalogName(),
			factory.getSettings().getDefaultSchemaName()
	);

	associateSubclassNamesToSubclassTableIndex( tableName, classNames, mapping );

	Iterator itr = persistentClass.getJoinIterator();
	while ( itr.hasNext() ) {
		final Join join = (Join) itr.next();
		final String secondaryTableName = join.getTable().getQualifiedName(
				factory.getDialect(),
				factory.getSettings().getDefaultCatalogName(),
				factory.getSettings().getDefaultSchemaName()
		);
		associateSubclassNamesToSubclassTableIndex( secondaryTableName, classNames, mapping );
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:26,代码来源:JoinedSubclassEntityPersister.java

示例13: buildProxyFactory

import org.hibernate.mapping.PersistentClass; //导入依赖的package包/类
@Override
   protected ProxyFactory buildProxyFactory(PersistentClass mappingInfo, Getter idGetter, Setter idSetter) {

	ProxyFactory pf = new MapProxyFactory();
	try {
		//TODO: design new lifecycle for ProxyFactory
		pf.postInstantiate(
				getEntityName(),
				null,
				null,
				null,
				null,
				null
		);
	}
	catch ( HibernateException he ) {
		LOG.unableToCreateProxyFactory( getEntityName(), he );
		pf = null;
	}
	return pf;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:DynamicMapEntityTuplizer.java

示例14: bindClass

import org.hibernate.mapping.PersistentClass; //导入依赖的package包/类
public static void bindClass(Element node, PersistentClass persistentClass, Mappings mappings,
		java.util.Map inheritedMetas) throws MappingException {
	// transfer an explicitly defined entity name
	// handle the lazy attribute
	Attribute lazyNode = node.attribute( "lazy" );
	boolean lazy = lazyNode == null ?
			mappings.isDefaultLazy() :
			"true".equals( lazyNode.getValue() );
	// go ahead and set the lazy here, since pojo.proxy can override it.
	persistentClass.setLazy( lazy );

	String entityName = node.attributeValue( "entity-name" );
	if ( entityName == null ) entityName = getClassName( node.attribute("name"), mappings );
	if ( entityName==null ) {
		throw new MappingException( "Unable to determine entity name" );
	}
	persistentClass.setEntityName( entityName );
	persistentClass.setJpaEntityName( StringHelper.unqualify( entityName ) );

	bindPojoRepresentation( node, persistentClass, mappings, inheritedMetas );
	bindDom4jRepresentation( node, persistentClass, mappings, inheritedMetas );
	bindMapRepresentation( node, persistentClass, mappings, inheritedMetas );

	Iterator itr = node.elementIterator( "fetch-profile" );
	while ( itr.hasNext() ) {
		final Element profileElement = ( Element ) itr.next();
		parseFetchProfile( profileElement, mappings, entityName );
	}

	bindPersistentClassCommonValues( node, persistentClass, mappings, inheritedMetas );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:32,代码来源:HbmBinder.java

示例15: bindDom4jRepresentation

import org.hibernate.mapping.PersistentClass; //导入依赖的package包/类
private static void bindDom4jRepresentation(Element node, PersistentClass entity,
			Mappings mappings, java.util.Map inheritedMetas) {
		String nodeName = node.attributeValue( "node" );
		if (nodeName==null) nodeName = StringHelper.unqualify( entity.getEntityName() );
		entity.setNodeName(nodeName);

//		Element tuplizer = locateTuplizerDefinition( node, EntityMode.DOM4J );
//		if ( tuplizer != null ) {
//			entity.addTuplizer( EntityMode.DOM4J, tuplizer.attributeValue( "class" ) );
//		}
	}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:12,代码来源:HbmBinder.java


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