类org.hibernate.tuple.AnnotationValueGeneration源码实例Demo

下面列出了怎么用org.hibernate.tuple.AnnotationValueGeneration的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: lams   文件: PropertyBinder.java
/**
 * Returns the value generation strategy for the given property, if any.
 */
private ValueGeneration getValueGenerationFromAnnotations(XProperty property) {
	AnnotationValueGeneration<?> valueGeneration = null;

	for ( Annotation annotation : property.getAnnotations() ) {
		AnnotationValueGeneration<?> candidate = getValueGenerationFromAnnotation( property, annotation );

		if ( candidate != null ) {
			if ( valueGeneration != null ) {
				throw new AnnotationException(
						"Only one generator annotation is allowed:" + StringHelper.qualify(
								holder.getPath(),
								name
						)
				);
			}
			else {
				valueGeneration = candidate;
			}
		}
	}

	return valueGeneration;
}
 
源代码2 项目: lams   文件: PropertyBinder.java
/**
 * 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;
}
 
 类所在包
 类方法
 同包方法