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


Java GenerationTiming类代码示例

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


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

示例1: determineValueGenerationStrategy

import org.hibernate.tuple.GenerationTiming; //导入依赖的package包/类
private ValueGeneration determineValueGenerationStrategy(XProperty property) {
	ValueGeneration valueGeneration = getValueGenerationFromAnnotations( property );

	if ( valueGeneration == null ) {
		return NoValueGeneration.INSTANCE;
	}

	final GenerationTiming when = valueGeneration.getGenerationTiming();

	if ( valueGeneration.getValueGenerator() == null ) {
		insertable = false;
		if ( when == GenerationTiming.ALWAYS ) {
			updatable = false;
		}
	}

	return valueGeneration;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:19,代码来源:PropertyBinder.java

示例2: GenerationStrategyPair

import org.hibernate.tuple.GenerationTiming; //导入依赖的package包/类
public GenerationStrategyPair(
		InMemoryValueGenerationStrategy inMemoryStrategy,
		InDatabaseValueGenerationStrategy inDatabaseStrategy) {
	// perform some normalization.  Also check that only one (if any) strategy is specified
	if ( inMemoryStrategy == null ) {
		inMemoryStrategy = NoInMemoryValueGenerationStrategy.INSTANCE;
	}
	if ( inDatabaseStrategy == null ) {
		inDatabaseStrategy = NoInDatabaseValueGenerationStrategy.INSTANCE;
	}

	if ( inMemoryStrategy.getGenerationTiming() != GenerationTiming.NEVER
			&& inDatabaseStrategy.getGenerationTiming() != GenerationTiming.NEVER ) {
		throw new ValueGenerationStrategyException(
				"in-memory and in-database value generation are mutually exclusive"
		);
	}

	this.inMemoryStrategy = inMemoryStrategy;
	this.inDatabaseStrategy = inDatabaseStrategy;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:EntityMetamodel.java

示例3: bindVersioningProperty

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

示例4: getValueGenerationFromAnnotation

import org.hibernate.tuple.GenerationTiming; //导入依赖的package包/类
/**
 * In case the given annotation is a value generator annotation, the corresponding value generation strategy to be
 * applied to the given property is returned, {@code null} otherwise.
 */
private <A extends Annotation> AnnotationValueGeneration<A> getValueGenerationFromAnnotation(
		XProperty property,
		A annotation) {
	ValueGenerationType generatorAnnotation = annotation.annotationType()
			.getAnnotation( ValueGenerationType.class );

	if ( generatorAnnotation == null ) {
		return null;
	}

	Class<? extends AnnotationValueGeneration<?>> generationType = generatorAnnotation.generatedBy();
	AnnotationValueGeneration<A> valueGeneration = instantiateAndInitializeValueGeneration(
			annotation, generationType, property
	);

	if ( annotation.annotationType() == Generated.class &&
			property.isAnnotationPresent( javax.persistence.Version.class ) &&
			valueGeneration.getGenerationTiming() == GenerationTiming.INSERT ) {

		throw new AnnotationException(
				"@Generated(INSERT) on a @Version property not allowed, use ALWAYS (or NEVER): "
						+ StringHelper.qualify( holder.getPath(), name )
		);
	}

	return valueGeneration;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:32,代码来源:PropertyBinder.java

示例5: buildGenerationStrategyPair

import org.hibernate.tuple.GenerationTiming; //导入依赖的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;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:32,代码来源:EntityMetamodel.java

示例6: add

import org.hibernate.tuple.GenerationTiming; //导入依赖的package包/类
private void add(InMemoryValueGenerationStrategy inMemoryStrategy) {
	if ( inMemoryStrategies == null ) {
		inMemoryStrategies = new ArrayList<InMemoryValueGenerationStrategy>();
	}
	inMemoryStrategies.add( inMemoryStrategy );

	if ( inMemoryStrategy.getGenerationTiming() != GenerationTiming.NEVER ) {
		hadInMemoryGeneration = true;
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:11,代码来源:EntityMetamodel.java

示例7: InDatabaseValueGenerationStrategyImpl

import org.hibernate.tuple.GenerationTiming; //导入依赖的package包/类
private InDatabaseValueGenerationStrategyImpl(
		GenerationTiming timing,
		boolean referenceColumnInSql,
		String[] referencedColumnValues) {
	this.timing = timing;
	this.referenceColumnInSql = referenceColumnInSql;
	this.referencedColumnValues = referencedColumnValues;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:EntityMetamodel.java

示例8: isNaturalIdentifierInsertGenerated

import org.hibernate.tuple.GenerationTiming; //导入依赖的package包/类
public boolean isNaturalIdentifierInsertGenerated() {
	// the intention is for this call to replace the usage of the old ValueInclusion stuff (as exposed from
	// persister) in SelectGenerator to determine if it is safe to use the natural identifier to find the
	// insert-generated identifier.  That wont work if the natural-id is also insert-generated.
	//
	// Assumptions:
	//		* That code checks that there is a natural identifier before making this call, so we assume the same here
	// 		* That code assumes a non-composite natural-id, so we assume the same here
	final InDatabaseValueGenerationStrategy strategy = inDatabaseValueGenerationStrategies[ naturalIdPropertyNumbers[0] ];
	return strategy != null && strategy.getGenerationTiming() != GenerationTiming.NEVER;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:12,代码来源:EntityMetamodel.java

示例9: getGenerationTiming

import org.hibernate.tuple.GenerationTiming; //导入依赖的package包/类
@Override
public GenerationTiming getGenerationTiming() {
	return GenerationTiming.NEVER;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:5,代码来源:PropertyBinder.java

示例10: generateInsertGeneratedValuesSelectString

import org.hibernate.tuple.GenerationTiming; //导入依赖的package包/类
protected String generateInsertGeneratedValuesSelectString() {
	return generateGeneratedValuesSelectString( GenerationTiming.INSERT );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:4,代码来源:AbstractEntityPersister.java

示例11: generateUpdateGeneratedValuesSelectString

import org.hibernate.tuple.GenerationTiming; //导入依赖的package包/类
protected String generateUpdateGeneratedValuesSelectString() {
	return generateGeneratedValuesSelectString( GenerationTiming.ALWAYS );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:4,代码来源:AbstractEntityPersister.java

示例12: generateGeneratedValuesSelectString

import org.hibernate.tuple.GenerationTiming; //导入依赖的package包/类
private String generateGeneratedValuesSelectString(final GenerationTiming generationTimingToMatch) {
	Select select = new Select( getFactory().getDialect() );

	if ( getFactory().getSettings().isCommentsEnabled() ) {
		select.setComment( "get generated state " + getEntityName() );
	}

	String[] aliasedIdColumns = StringHelper.qualify( getRootAlias(), getIdentifierColumnNames() );

	// Here we render the select column list based on the properties defined as being generated.
	// For partial component generation, we currently just re-select the whole component
	// rather than trying to handle the individual generated portions.
	String selectClause = concretePropertySelectFragment(
			getRootAlias(),
			new InclusionChecker() {
				@Override
				public boolean includeProperty(int propertyNumber) {
					final InDatabaseValueGenerationStrategy generationStrategy
							= entityMetamodel.getInDatabaseValueGenerationStrategies()[propertyNumber];
					return generationStrategy != null
							&& timingsMatch( generationStrategy.getGenerationTiming(), generationTimingToMatch );
				}
			}
	);
	selectClause = selectClause.substring( 2 );

	String fromClause = fromTableFragment( getRootAlias() ) +
			fromJoinFragment( getRootAlias(), true, false );

	String whereClause = new StringBuilder()
			.append( StringHelper.join( "=? and ", aliasedIdColumns ) )
			.append( "=?" )
			.append( whereJoinFragment( getRootAlias(), true, false ) )
			.toString();

	return select.setSelectClause( selectClause )
			.setFromClause( fromClause )
			.setOuterJoins( "", "" )
			.setWhereClause( whereClause )
			.toStatementString();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:42,代码来源:AbstractEntityPersister.java

示例13: processInsertGeneratedProperties

import org.hibernate.tuple.GenerationTiming; //导入依赖的package包/类
public void processInsertGeneratedProperties(Serializable id, Object entity, Object[] state, SessionImplementor session) {
	if ( !hasInsertGeneratedProperties() ) {
		throw new AssertionFailure("no insert-generated properties");
	}
	processGeneratedProperties( id, entity, state, session, sqlInsertGeneratedValuesSelectString, GenerationTiming.INSERT );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:7,代码来源:AbstractEntityPersister.java

示例14: processUpdateGeneratedProperties

import org.hibernate.tuple.GenerationTiming; //导入依赖的package包/类
public void processUpdateGeneratedProperties(Serializable id, Object entity, Object[] state, SessionImplementor session) {
	if ( !hasUpdateGeneratedProperties() ) {
		throw new AssertionFailure("no update-generated properties");
	}
	processGeneratedProperties( id, entity, state, session, sqlUpdateGeneratedValuesSelectString, GenerationTiming.ALWAYS );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:7,代码来源:AbstractEntityPersister.java

示例15: processGeneratedProperties

import org.hibernate.tuple.GenerationTiming; //导入依赖的package包/类
private void processGeneratedProperties(
			Serializable id,
	        Object entity,
	        Object[] state,
	        SessionImplementor session,
	        String selectionSQL,
			GenerationTiming matchTiming) {
		// force immediate execution of the insert batch (if one)
		session.getTransactionCoordinator().getJdbcCoordinator().executeBatch();

		try {
			PreparedStatement ps = session.getTransactionCoordinator()
					.getJdbcCoordinator()
					.getStatementPreparer()
					.prepareStatement( selectionSQL );
			try {
				getIdentifierType().nullSafeSet( ps, id, 1, session );
				ResultSet rs = session.getTransactionCoordinator().getJdbcCoordinator().getResultSetReturn().extract( ps );
				try {
					if ( !rs.next() ) {
						throw new HibernateException(
								"Unable to locate row for retrieval of generated properties: " +
								MessageHelper.infoString( this, id, getFactory() )
							);
					}
					int propertyIndex = -1;
					for ( NonIdentifierAttribute attribute : entityMetamodel.getProperties() ) {
						propertyIndex++;
						final ValueGeneration valueGeneration = attribute.getValueGenerationStrategy();
						if ( isReadRequired( valueGeneration, matchTiming ) ) {
							final Object hydratedState = attribute.getType().hydrate(
									rs, getPropertyAliases(
									"",
									propertyIndex
							), session, entity
							);
							state[propertyIndex] = attribute.getType().resolve( hydratedState, session, entity );
							setPropertyValue( entity, propertyIndex, state[propertyIndex] );
						}
					}
//					for ( int i = 0; i < getPropertySpan(); i++ ) {
//						if ( includeds[i] != ValueInclusion.NONE ) {
//							Object hydratedState = getPropertyTypes()[i].hydrate( rs, getPropertyAliases( "", i ), session, entity );
//							state[i] = getPropertyTypes()[i].resolve( hydratedState, session, entity );
//							setPropertyValue( entity, i, state[i] );
//						}
//					}
				}
				finally {
					if ( rs != null ) {
						session.getTransactionCoordinator().getJdbcCoordinator().release( rs, ps );
					}
				}
			}
			finally {
				session.getTransactionCoordinator().getJdbcCoordinator().release( ps );
			}
		}
		catch( SQLException e ) {
			throw getFactory().getSQLExceptionHelper().convert(
					e,
					"unable to select generated column values",
					selectionSQL
			);
		}

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


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