org.hibernate.mapping.RootClass#setCacheRegionName ( )源码实例Demo

下面列出了org.hibernate.mapping.RootClass#setCacheRegionName ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: cacheonix-core   文件: Configuration.java
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 );
}
 
源代码2 项目: lams   文件: ModelBinder.java
private void applyCaching(MappingDocument mappingDocument, Caching caching, RootClass rootEntityDescriptor) {
	if ( caching == null || caching.getRequested() == TruthValue.UNKNOWN ) {
		// see if JPA's SharedCacheMode indicates we should implicitly apply caching
		//
		// here we only really look for ALL.  Ideally we could look at NONE too as a means
		// to selectively disable all caching, but historically hbm.xml mappings were processed
		// outside this concept and whether to cache or not was defined wholly by what
		// is defined in the mapping document.  So for backwards compatibility we
		// do not consider ENABLE_SELECTIVE nor DISABLE_SELECTIVE here.
		//
		// Granted, ALL was not historically considered either, but I have a practical
		// reason for wanting to support this... our legacy tests built using
		// Configuration applied a similar logic but that capability is no longer
		// accessible from Configuration
		switch ( mappingDocument.getBuildingOptions().getSharedCacheMode() ) {
			case ALL: {
				caching = new Caching(
						null,
						mappingDocument.getBuildingOptions().getImplicitCacheAccessType(),
						false,
						TruthValue.UNKNOWN
				);
				break;
			}
			case NONE: {
				// Ideally we'd disable all caching...
				break;
			}
			case ENABLE_SELECTIVE: {
				// this is default behavior for hbm.xml
				break;
			}
			case DISABLE_SELECTIVE: {
				// really makes no sense for hbm.xml
				break;
			}
			default: {
				// null or UNSPECIFIED, nothing to do.  IMO for hbm.xml this is equivalent
				// to ENABLE_SELECTIVE
				break;
			}
		}
	}

	if ( caching == null || caching.getRequested() == TruthValue.FALSE ) {
		return;
	}

	if ( caching.getAccessType() != null ) {
		rootEntityDescriptor.setCacheConcurrencyStrategy( caching.getAccessType().getExternalName() );
	}
	else {
		rootEntityDescriptor.setCacheConcurrencyStrategy( mappingDocument.getBuildingOptions().getImplicitCacheAccessType().getExternalName() );
	}
	rootEntityDescriptor.setCacheRegionName( caching.getRegion() );
	rootEntityDescriptor.setLazyPropertiesCacheable( caching.isCacheLazyProperties() );
	rootEntityDescriptor.setCached( caching.getRequested() != TruthValue.UNKNOWN );
}
 
源代码3 项目: cacheonix-core   文件: HbmBinder.java
private static void bindRootPersistentClassCommonValues(Element node,
		java.util.Map inheritedMetas, Mappings mappings, RootClass entity)
		throws MappingException {

	// DB-OBJECTNAME

	Attribute schemaNode = node.attribute( "schema" );
	String schema = schemaNode == null ?
			mappings.getSchemaName() : schemaNode.getValue();

	Attribute catalogNode = node.attribute( "catalog" );
	String catalog = catalogNode == null ?
			mappings.getCatalogName() : catalogNode.getValue();

	Table table = mappings.addTable(
			schema,
			catalog,
			getClassTableName( entity, node, schema, catalog, null, mappings ),
			getSubselect( node ),
	        entity.isAbstract() != null && entity.isAbstract().booleanValue()
		);
	entity.setTable( table );
	bindComment(table, node);

	log.info(
			"Mapping class: " + entity.getEntityName() +
			" -> " + entity.getTable().getName()
		);

	// MUTABLE
	Attribute mutableNode = node.attribute( "mutable" );
	entity.setMutable( ( mutableNode == null ) || mutableNode.getValue().equals( "true" ) );

	// WHERE
	Attribute whereNode = node.attribute( "where" );
	if ( whereNode != null ) entity.setWhere( whereNode.getValue() );

	// CHECK
	Attribute chNode = node.attribute( "check" );
	if ( chNode != null ) table.addCheckConstraint( chNode.getValue() );

	// POLYMORPHISM
	Attribute polyNode = node.attribute( "polymorphism" );
	entity.setExplicitPolymorphism( ( polyNode != null )
		&& polyNode.getValue().equals( "explicit" ) );

	// ROW ID
	Attribute rowidNode = node.attribute( "rowid" );
	if ( rowidNode != null ) table.setRowId( rowidNode.getValue() );

	Iterator subnodes = node.elementIterator();
	while ( subnodes.hasNext() ) {

		Element subnode = (Element) subnodes.next();
		String name = subnode.getName();

		if ( "id".equals( name ) ) {
			// ID
			bindSimpleId( subnode, entity, mappings, inheritedMetas );
		}
		else if ( "composite-id".equals( name ) ) {
			// COMPOSITE-ID
			bindCompositeId( subnode, entity, mappings, inheritedMetas );
		}
		else if ( "version".equals( name ) || "timestamp".equals( name ) ) {
			// VERSION / TIMESTAMP
			bindVersioningProperty( table, subnode, mappings, name, entity, inheritedMetas );
		}
		else if ( "discriminator".equals( name ) ) {
			// DISCRIMINATOR
			bindDiscriminatorProperty( table, entity, subnode, mappings );
		}
		else if ( "cache".equals( name ) ) {
			entity.setCacheConcurrencyStrategy( subnode.attributeValue( "usage" ) );
			entity.setCacheRegionName( subnode.attributeValue( "region" ) );
			entity.setLazyPropertiesCacheable( !"non-lazy".equals( subnode.attributeValue( "include" ) ) );
		}

	}

	// Primary key constraint
	entity.createPrimaryKey();

	createClassProperties( node, entity, mappings, inheritedMetas );
}