本文整理汇总了Java中org.hibernate.mapping.RootClass类的典型用法代码示例。如果您正苦于以下问题:Java RootClass类的具体用法?Java RootClass怎么用?Java RootClass使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RootClass类属于org.hibernate.mapping包,在下文中一共展示了RootClass类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 );
}
}
示例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() );
}
}
}
示例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 );
}
示例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);
}
示例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 );
}
}
示例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 );
}
示例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 );
}
示例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 );
}
}
示例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 );
}
示例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 );
}
示例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 );
}
示例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" );
}
}
示例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 );
}
示例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);
}
示例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
);
}