类org.hibernate.annotations.Immutable源码实例Demo

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

源代码1 项目: lams   文件: JavaTypeDescriptorRegistry.java
@SuppressWarnings("unchecked")
private static <T> MutabilityPlan<T> createMutabilityPlan(final Class<T> type) {
	if ( type.isAnnotationPresent( Immutable.class ) ) {
		return ImmutableMutabilityPlan.INSTANCE;
	}
	// MutableMutabilityPlan is the "safest" option, but we do not necessarily know how to deepCopy etc...
	return new MutableMutabilityPlan<T>() {
		@Override
		protected T deepCopyNotNull(T value) {
			throw new HibernateException(
					"Not known how to deep copy value of type: [" + type
							.getName() + "]"
			);
		}
	};
}
 
源代码2 项目: lams   文件: PropertyBinder.java
private void validateBind() {
	if ( property.isAnnotationPresent( Immutable.class ) ) {
		throw new AnnotationException(
				"@Immutable on property not allowed. " +
						"Only allowed on entity level or on a collection."
		);
	}
	if ( !declaringClassSet ) {
		throw new AssertionFailure( "declaringClass has not been set before a bind" );
	}
}
 
源代码3 项目: lams   文件: SerializableTypeDescriptor.java
@SuppressWarnings({ "unchecked" })
private static <T> MutabilityPlan<T> createMutabilityPlan(Class<T> type) {
	if ( type.isAnnotationPresent( Immutable.class ) ) {
		return ImmutableMutabilityPlan.INSTANCE;
	}
	return (MutabilityPlan<T>) SerializableMutabilityPlan.INSTANCE;
}
 
 类所在包
 同包方法