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

Java RootClass类代码示例

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

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



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

示例1: bindDiscriminatorProperty

import org.hibernate.mapping.RootClass; //导入依赖的package包/类
private static void bindDiscriminatorProperty(Table table, RootClass entity, Element subnode,
		Mappings mappings) {
	SimpleValue discrim = new SimpleValue( mappings, table );
	entity.setDiscriminator( discrim );
	bindSimpleValue(
			subnode,
			discrim,
			false,
			RootClass.DEFAULT_DISCRIMINATOR_COLUMN_NAME,
			mappings
		);
	if ( !discrim.isTypeSpecified() ) {
		discrim.setTypeName( "string" );
		// ( (Column) discrim.getColumnIterator().next() ).setType(type);
	}
	entity.setPolymorphic( true );
	final String explicitForceValue = subnode.attributeValue( "force" );
	boolean forceDiscriminatorInSelects = explicitForceValue == null
			? mappings.forceDiscriminatorInSelectsByDefault()
			: "true".equals( explicitForceValue );
	entity.setForceDiscriminator( forceDiscriminatorInSelects );
	if ( "false".equals( subnode.attributeValue( "insert" ) ) ) {
		entity.setDiscriminatorInsertable( false );
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:26,代码来源:HbmBinder.java


示例2: bindDiscriminatorColumnToRootPersistentClass

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


示例3: bindDiscriminatorProperty

import org.hibernate.mapping.RootClass; //导入依赖的package包/类
private static void bindDiscriminatorProperty(Table table, RootClass entity, Element subnode,
		Mappings mappings) {
	SimpleValue discrim = new SimpleValue( table );
	entity.setDiscriminator( discrim );
	bindSimpleValue(
			subnode,
			discrim,
			false,
			RootClass.DEFAULT_DISCRIMINATOR_COLUMN_NAME,
			mappings
		);
	if ( !discrim.isTypeSpecified() ) {
		discrim.setTypeName( "string" );
		// ( (Column) discrim.getColumnIterator().next() ).setType(type);
	}
	entity.setPolymorphic( true );
	if ( "true".equals( subnode.attributeValue( "force" ) ) )
		entity.setForceDiscriminator( true );
	if ( "false".equals( subnode.attributeValue( "insert" ) ) )
		entity.setDiscriminatorInsertable( false );
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:22,代码来源:HbmBinder.java


示例4: testProperCallbacks

import org.hibernate.mapping.RootClass; //导入依赖的package包/类
public void testProperCallbacks() {

		ValueVisitor vv = new ValueVisitorValidator();
		
		new Any(new Table()).accept(vv);
		new Array(new RootClass()).accept(vv);
		new Bag(new RootClass()).accept(vv);
		new Component(new RootClass()).accept(vv);
		new DependantValue(null,null).accept(vv);
		new IdentifierBag(null).accept(vv);
		new List(null).accept(vv);
		new ManyToOne(null).accept(vv);
		new Map(null).accept(vv);
		new OneToMany(null).accept(vv);
		new OneToOne(null, new RootClass() ).accept(vv);
		new PrimitiveArray(null).accept(vv);
		new Set(null).accept(vv);
		new SimpleValue().accept(vv);
	
		
	}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:22,代码来源:ValueVisitorTest.java


示例5: resolveIdentifierTable

import org.hibernate.mapping.RootClass; //导入依赖的package包/类
private static Table resolveIdentifierTable(
			PersisterCreationContext creationContext,
			RootClass rootEntityBinding) {
//		final JdbcEnvironment jdbcEnvironment = creationContext.getSessionFactory()
//				.getJdbcServices()
//				.getJdbcEnvironment();
		final org.hibernate.mapping.Table mappingTable = rootEntityBinding.getIdentityTable();
		if ( mappingTable.getSubselect() != null ) {
			return creationContext.getDatabaseModel().findDerivedTable( mappingTable.getSubselect() );
		}
		else {
//			final String name = jdbcEnvironment.getQualifiedObjectNameFormatter().format(
//					mappingTable.getQualifiedTableName(),
//					jdbcEnvironment.getDialect()
//			);
			final String name = mappingTable.getQualifiedTableName().render();
			return creationContext.getDatabaseModel().findPhysicalTable( name );

		}
	}
 
开发者ID:hibernate,项目名称:hibernate-semantic-query,代码行数:21,代码来源:EntityHierarchyImpl.java


示例6: bindCompositeId

import org.hibernate.mapping.RootClass; //导入依赖的package包/类
private static void bindCompositeId(Element idNode, RootClass entity, Mappings mappings,
		java.util.Map inheritedMetas) throws MappingException {
	String propertyName = idNode.attributeValue( "name" );
	Component id = new Component( mappings, entity );
	entity.setIdentifier( id );
	bindCompositeId( idNode, id, entity, propertyName, mappings, inheritedMetas );
	if ( propertyName == null ) {
		entity.setEmbeddedIdentifier( id.isEmbedded() );
		if ( id.isEmbedded() ) {
			// todo : what is the implication of this?
			id.setDynamic( !entity.hasPojoRepresentation() );
			/*
			 * Property prop = new Property(); prop.setName("id");
			 * prop.setPropertyAccessorName("embedded"); prop.setValue(id);
			 * entity.setIdentifierProperty(prop);
			 */
		}
	}
	else {
		Property prop = new Property();
		prop.setValue( id );
		bindProperty( idNode, prop, mappings, inheritedMetas );
		entity.setIdentifierProperty( prop );
		entity.setDeclaredIdentifierProperty( prop );
	}

	makeIdentifier( idNode, id, mappings );

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


示例7: bindVersioningProperty

import org.hibernate.mapping.RootClass; //导入依赖的package包/类
private static void bindVersioningProperty(Table table, Element subnode, Mappings mappings,
		String name, RootClass entity, java.util.Map inheritedMetas) {

	String propertyName = subnode.attributeValue( "name" );
	SimpleValue val = new SimpleValue( mappings, table );
	bindSimpleValue( subnode, val, false, propertyName, mappings );
	if ( !val.isTypeSpecified() ) {
		// this is either a <version/> tag with no type attribute,
		// or a <timestamp/> tag
		if ( "version".equals( name ) ) {
			val.setTypeName( "integer" );
		}
		else {
			if ( "db".equals( subnode.attributeValue( "source" ) ) ) {
				val.setTypeName( "dbtimestamp" );
			}
			else {
				val.setTypeName( "timestamp" );
			}
		}
	}
	Property prop = new Property();
	prop.setValue( val );
	bindProperty( subnode, prop, mappings, inheritedMetas );
	// for version properties marked as being generated, make sure they are "always"
	// generated; aka, "insert" is invalid; this is dis-allowed by the DTD,
	// but just to make sure...
	if ( prop.getValueGenerationStrategy() != null ) {
		if ( prop.getValueGenerationStrategy().getGenerationTiming() == GenerationTiming.INSERT ) {
			throw new MappingException( "'generated' attribute cannot be 'insert' for versioning property" );
		}
	}
	makeVersion( subnode, val );
	entity.setVersion( prop );
	entity.addProperty( prop );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:37,代码来源:HbmBinder.java


示例8: getRootClassMapping

import org.hibernate.mapping.RootClass; //导入依赖的package包/类
RootClass getRootClassMapping(String clazz) throws MappingException {
	try {
		return (RootClass) getClassMapping( clazz );
	}
	catch (ClassCastException cce) {
		throw new MappingException( "You may only specify a cache for root <class> mappings.  Attempted on " + clazz );
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:Configuration.java


示例9: applyCacheConcurrencyStrategy

import org.hibernate.mapping.RootClass; //导入依赖的package包/类
private void applyCacheConcurrencyStrategy(CacheHolder holder) {
	RootClass rootClass = getRootClassMapping( holder.role );
	if ( rootClass == null ) {
		throw new MappingException( "Cannot cache an unknown entity: " + holder.role );
	}
	rootClass.setCacheConcurrencyStrategy( holder.usage );
	rootClass.setCacheRegionName( holder.region );
	rootClass.setLazyPropertiesCacheable( holder.cacheLazy );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:Configuration.java


示例10: bindCompositeId

import org.hibernate.mapping.RootClass; //导入依赖的package包/类
private static void bindCompositeId(Element idNode, RootClass entity, Mappings mappings,
		java.util.Map inheritedMetas) throws MappingException {
	String propertyName = idNode.attributeValue( "name" );
	Component id = new Component( entity );
	entity.setIdentifier( id );
	bindCompositeId( idNode, id, entity, propertyName, mappings, inheritedMetas );
	if ( propertyName == null ) {
		entity.setEmbeddedIdentifier( id.isEmbedded() );
		if ( id.isEmbedded() ) {
			// todo : what is the implication of this?
			id.setDynamic( !entity.hasPojoRepresentation() );
			/*
			 * Property prop = new Property(); prop.setName("id");
			 * prop.setPropertyAccessorName("embedded"); prop.setValue(id);
			 * entity.setIdentifierProperty(prop);
			 */
		}
	}
	else {
		Property prop = new Property();
		prop.setValue( id );
		bindProperty( idNode, prop, mappings, inheritedMetas );
		entity.setIdentifierProperty( prop );
	}

	makeIdentifier( idNode, id, mappings );

}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:29,代码来源:HbmBinder.java


示例11: bindVersioningProperty

import org.hibernate.mapping.RootClass; //导入依赖的package包/类
private static void bindVersioningProperty(Table table, Element subnode, Mappings mappings,
		String name, RootClass entity, java.util.Map inheritedMetas) {

	String propertyName = subnode.attributeValue( "name" );
	SimpleValue val = new SimpleValue( table );
	bindSimpleValue( subnode, val, false, propertyName, mappings );
	if ( !val.isTypeSpecified() ) {
		// this is either a <version/> tag with no type attribute,
		// or a <timestamp/> tag
		if ( "version".equals( name ) ) {
			val.setTypeName( "integer" );
		}
		else {
			if ( "db".equals( subnode.attributeValue( "source" ) ) ) {
				val.setTypeName( "dbtimestamp" );
			}
			else {
				val.setTypeName( "timestamp" );
			}
		}
	}
	Property prop = new Property();
	prop.setValue( val );
	bindProperty( subnode, prop, mappings, inheritedMetas );
	// for version properties marked as being generated, make sure they are "always"
	// generated; aka, "insert" is invalid; this is dis-allowed by the DTD,
	// but just to make sure...
	if ( prop.getGeneration() == PropertyGeneration.INSERT ) {
		throw new MappingException( "'generated' attribute cannot be 'insert' for versioning property" );
	}
	makeVersion( subnode, val );
	entity.setVersion( prop );
	entity.addProperty( prop );
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:35,代码来源:HbmBinder.java


示例12: getRootClassMapping

import org.hibernate.mapping.RootClass; //导入依赖的package包/类
RootClass getRootClassMapping(String clazz) throws MappingException {
	try {
		return (RootClass) getClassMapping( clazz );
	}
	catch (ClassCastException cce) {
		throw new MappingException( "You may only specify a cache for root <class> mappings" );
	}
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:9,代码来源:Configuration.java


示例13: setCacheConcurrencyStrategy

import org.hibernate.mapping.RootClass; //导入依赖的package包/类
void setCacheConcurrencyStrategy(String clazz, String concurrencyStrategy, String region, boolean includeLazy)
		throws MappingException {
	RootClass rootClass = getRootClassMapping( clazz );
	if ( rootClass == null ) {
		throw new MappingException( "Cannot cache an unknown entity: " + clazz );
	}
	rootClass.setCacheConcurrencyStrategy( concurrencyStrategy );
	rootClass.setCacheRegionName( region );
	rootClass.setLazyPropertiesCacheable( includeLazy );
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:11,代码来源:Configuration.java


示例14: testProperCallbacks

import org.hibernate.mapping.RootClass; //导入依赖的package包/类
public void testProperCallbacks() {

		PersistentClassVisitorValidator vv = new PersistentClassVisitorValidator();

		new RootClass().accept(vv);
		new Subclass(new RootClass()).accept(vv);
		new JoinedSubclass(new RootClass()).accept(vv);
		new SingleTableSubclass(new RootClass()).accept(vv);
		new UnionSubclass(new RootClass()).accept(vv);

	}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:12,代码来源:PersistentClassVisitorTest.java


示例15: EntityHierarchyImpl

import org.hibernate.mapping.RootClass; //导入依赖的package包/类
public EntityHierarchyImpl(
		PersisterCreationContext creationContext,
		RootClass rootEntityBinding,
		EntityPersister rootEntityPersister) {
	this.rootEntityPersister = rootEntityPersister;

	final Table identifierTable = resolveIdentifierTable( creationContext, rootEntityBinding );
	this.identifierDescriptor = interpretIdentifierDescriptor(
			this,
			rootEntityPersister,
			creationContext,
			rootEntityBinding,
			identifierTable
	);
}
 
开发者ID:hibernate,项目名称:hibernate-semantic-query,代码行数:16,代码来源:EntityHierarchyImpl.java


示例16: finishUp

import org.hibernate.mapping.RootClass; //导入依赖的package包/类
@Override
public void finishUp(PersisterCreationContext creationContext) {
	for ( EntityHierarchyNode root : roots ) {
		// todo : resolve any MappedSuperclasses for supers of the root entity
		EntityHierarchy entityHierarchy = new EntityHierarchyImpl(
				creationContext,
				(RootClass) root.mappingType,
				(EntityPersister) root.ormJpaType
		);

		finishSupers( root.superEntityNode, entityHierarchy, creationContext );

		root.finishUp( entityHierarchy, creationContext );

		entityHierarchy.finishInitialization( creationContext, (RootClass) root.mappingType );
	}

	// todo :
	for ( final Collection model : creationContext.getMetadata().getCollectionBindings() ) {
		final CollectionPersister collectionPersister = creationContext.getTypeConfiguration().findCollectionPersister( model.getRole() );
		if ( collectionPersister == null ) {
			throw new HibernateException( "Collection role not properly materialized to CollectionPersister : " + model.getRole() );
		}
		collectionPersister.finishInitialization( model, creationContext );
	}

	for ( EmbeddableMapper mapper : creationContext.getTypeConfiguration().getEmbeddablePersisters() ) {
		mapper.afterInitialization(
				embeddableComponentMap.get( mapper ),
				creationContext
		);
	}


	serviceRegistry = null;
	roots.clear();
	nameToHierarchyNodeMap.clear();
	embeddableComponentMap.clear();
}
 
开发者ID:hibernate,项目名称:hibernate-semantic-query,代码行数:40,代码来源:PersisterFactoryImpl.java


示例17: startHibernate

import org.hibernate.mapping.RootClass; //导入依赖的package包/类
/**
 * @param accessType Cache access typr.
 * @param igniteInstanceName Name of the grid providing caches.
 * @return Session factory.
 */
private SessionFactory startHibernate(AccessType accessType, String igniteInstanceName) {
    StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder();

    builder.applySetting("hibernate.connection.url", CONNECTION_URL);

    for (Map.Entry<String, String> e : HibernateL2CacheSelfTest.hibernateProperties(igniteInstanceName, accessType.name()).entrySet())
        builder.applySetting(e.getKey(), e.getValue());

    builder.applySetting(USE_STRUCTURED_CACHE, "true");
    builder.applySetting(REGION_CACHE_PROPERTY + ENTITY1_NAME, "cache1");
    builder.applySetting(REGION_CACHE_PROPERTY + ENTITY2_NAME, "cache2");
    builder.applySetting(REGION_CACHE_PROPERTY + TIMESTAMP_CACHE, TIMESTAMP_CACHE);
    builder.applySetting(REGION_CACHE_PROPERTY + QUERY_CACHE, QUERY_CACHE);

    MetadataSources metadataSources = new MetadataSources(builder.build());

    metadataSources.addAnnotatedClass(Entity1.class);
    metadataSources.addAnnotatedClass(Entity2.class);
    metadataSources.addAnnotatedClass(Entity3.class);
    metadataSources.addAnnotatedClass(Entity4.class);

    Metadata metadata = metadataSources.buildMetadata();

    for (PersistentClass entityBinding : metadata.getEntityBindings()) {
        if (!entityBinding.isInherited())
            ((RootClass)entityBinding).setCacheConcurrencyStrategy(accessType.getExternalName());
    }

    return metadata.buildSessionFactory();
}
 
开发者ID:apache,项目名称:ignite,代码行数:36,代码来源:HibernateL2CacheStrategySelfTest.java


示例18: startHibernate

import org.hibernate.mapping.RootClass; //导入依赖的package包/类
/**
 * Starts Hibernate.
 *
 * @param accessType Cache access type.
 * @param igniteInstanceName Ignite instance name.
 * @return Session factory.
 */
private SessionFactory startHibernate(org.hibernate.cache.spi.access.AccessType accessType, String igniteInstanceName) {
    StandardServiceRegistryBuilder builder = registryBuilder();

    for (Map.Entry<String, String> e : hibernateProperties(igniteInstanceName, accessType.name()).entrySet())
        builder.applySetting(e.getKey(), e.getValue());

    // Use the same cache for Entity and Entity2.
    builder.applySetting(REGION_CACHE_PROPERTY + ENTITY2_NAME, ENTITY_NAME);

    StandardServiceRegistry srvcRegistry = builder.build();

    MetadataSources metadataSources = new MetadataSources(srvcRegistry);

    for (Class entityClass : getAnnotatedClasses())
        metadataSources.addAnnotatedClass(entityClass);

    Metadata metadata = metadataSources.buildMetadata();

    for (PersistentClass entityBinding : metadata.getEntityBindings()) {
        if (!entityBinding.isInherited())
            ((RootClass)entityBinding).setCacheConcurrencyStrategy(accessType.getExternalName());
    }

    for (org.hibernate.mapping.Collection collectionBinding : metadata.getCollectionBindings())
        collectionBinding.setCacheConcurrencyStrategy(accessType.getExternalName() );

    return metadata.buildSessionFactory();
}
 
开发者ID:apache,项目名称:ignite,代码行数:36,代码来源:HibernateL2CacheSelfTest.java


示例19: getClassDiscriminatorValue

import org.hibernate.mapping.RootClass; //导入依赖的package包/类
public Object getClassDiscriminatorValue(String classname) throws TypesInformationException {
    Object identifier = discriminators.get(classname);
    if (identifier == null) {
        PersistentClass clazz = configuration.getClassMapping(classname);
        if (clazz != null) {
            if (clazz instanceof Subclass) {
                Subclass sub = (Subclass) clazz;
                if (sub.isJoinedSubclass()) {
                    identifier = Integer.valueOf(sub.getSubclassId());
                } else {
                    identifier = getShortClassName(classname);
                }
            } else if (clazz instanceof RootClass) {
                RootClass root = (RootClass) clazz;
                if (root.getDiscriminator() == null) {
                    identifier = Integer.valueOf(root.getSubclassId());
                } else {
                    identifier = getShortClassName(classname);
                }
            }
        } else {
            throw new TypesInformationException("Class " + classname + " not found in hibernate configuration");
        }
        discriminators.put(classname, identifier);
    }
    return identifier;
}
 
开发者ID:NCIP,项目名称:cagrid-core,代码行数:28,代码来源:HibernateConfigTypesInformationResolver.java


示例20: getClassDiscriminatorValue

import org.hibernate.mapping.RootClass; //导入依赖的package包/类
public Object getClassDiscriminatorValue(String classname) throws TypesInformationException {
	LOG.debug("Getting class discriminator value for " + classname);
    Object identifier = discriminators.get(classname);
    if (identifier == null) {
        PersistentClass clazz = configuration.getClassMapping(classname);
        if (clazz != null) {
            if (clazz instanceof Subclass) {
            	Subclass sub = (Subclass) clazz;
                if (sub.isJoinedSubclass()) {
                	LOG.debug("\t" + classname + " is a joined subclass");
                    identifier = Integer.valueOf(sub.getSubclassId());
                } else {
                	LOG.debug("\t" + classname + " is a named subclass");
                    identifier = getShortClassName(classname);
                }
            } else if (clazz instanceof RootClass) {
            	LOG.debug("\t" + classname + " is a root class");
                RootClass root = (RootClass) clazz;
                if (root.getDiscriminator() == null) {
                    identifier = Integer.valueOf(root.getSubclassId());
                } else {
                    identifier = getShortClassName(classname);
                }
            }
        } else {
            throw new TypesInformationException("Class " + classname + " not found in hibernate configuration");
        }
        discriminators.put(classname, identifier);
    }
    return identifier;
}
 
开发者ID:NCIP,项目名称:cagrid-core,代码行数:32,代码来源:HibernateConfigTypesInformationResolver.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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