本文整理汇总了Java中org.hibernate.mapping.Property.getValueGenerationStrategy方法的典型用法代码示例。如果您正苦于以下问题:Java Property.getValueGenerationStrategy方法的具体用法?Java Property.getValueGenerationStrategy怎么用?Java Property.getValueGenerationStrategy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.hibernate.mapping.Property
的用法示例。
在下文中一共展示了Property.getValueGenerationStrategy方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: bindVersioningProperty
import org.hibernate.mapping.Property; //导入方法依赖的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 );
}
示例2: buildGenerationStrategyPair
import org.hibernate.mapping.Property; //导入方法依赖的package包/类
private static GenerationStrategyPair buildGenerationStrategyPair(
final SessionFactoryImplementor sessionFactory,
final Property mappingProperty) {
final ValueGeneration valueGeneration = mappingProperty.getValueGenerationStrategy();
if ( valueGeneration != null && valueGeneration.getGenerationTiming() != GenerationTiming.NEVER ) {
// the property is generated in full. build the generation strategy pair.
if ( valueGeneration.getValueGenerator() != null ) {
// in-memory generation
return new GenerationStrategyPair(
FullInMemoryValueGenerationStrategy.create( valueGeneration )
);
}
else {
// in-db generation
return new GenerationStrategyPair(
create(
sessionFactory,
mappingProperty,
valueGeneration
)
);
}
}
else if ( mappingProperty.getValue() instanceof Component ) {
final CompositeGenerationStrategyPairBuilder builder = new CompositeGenerationStrategyPairBuilder( mappingProperty );
interpretPartialCompositeValueGeneration( sessionFactory, (Component) mappingProperty.getValue(), builder );
return builder.buildPair();
}
return NO_GEN_PAIR;
}
示例3: buildStandardProperty
import org.hibernate.mapping.Property; //导入方法依赖的package包/类
@Deprecated
public static StandardProperty buildStandardProperty(Property property, boolean lazyAvailable) {
final Type type = property.getValue().getType();
// we need to dirty check collections, since they can cause an owner
// version number increment
// we need to dirty check many-to-ones with not-found="ignore" in order
// to update the cache (not the database), since in this case a null
// entity reference can lose information
boolean alwaysDirtyCheck = type.isAssociationType() &&
( (AssociationType) type ).isAlwaysDirtyChecked();
return new StandardProperty(
property.getName(),
type,
lazyAvailable && property.isLazy(),
property.isInsertable(),
property.isUpdateable(),
property.getValueGenerationStrategy(),
property.isOptional(),
alwaysDirtyCheck || property.isUpdateable(),
property.isOptimisticLocked(),
property.getCascadeStyle(),
property.getValue().getFetchMode()
);
}
示例4: isInsertGenerated
import org.hibernate.mapping.Property; //导入方法依赖的package包/类
private boolean isInsertGenerated(Property property) {
return property.getValueGenerationStrategy() != null
&& property.getValueGenerationStrategy().getGenerationTiming() != GenerationTiming.NEVER;
}
示例5: isUpdateGenerated
import org.hibernate.mapping.Property; //导入方法依赖的package包/类
private static boolean isUpdateGenerated(Property property) {
return property.getValueGenerationStrategy() != null
&& property.getValueGenerationStrategy().getGenerationTiming() == GenerationTiming.ALWAYS;
}