Java Code Examples for org.hibernate.annotations.Immutable

The following examples show how to use org.hibernate.annotations.Immutable. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@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() + "]"
			);
		}
	};
}
 
Example 2
Source Project: lams   Source File: PropertyBinder.java    License: GNU General Public License v2.0 5 votes vote down vote up
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" );
	}
}
 
Example 3
@SuppressWarnings({ "unchecked" })
private static <T> MutabilityPlan<T> createMutabilityPlan(Class<T> type) {
	if ( type.isAnnotationPresent( Immutable.class ) ) {
		return ImmutableMutabilityPlan.INSTANCE;
	}
	return (MutabilityPlan<T>) SerializableMutabilityPlan.INSTANCE;
}