org.hibernate.annotations.Immutable Java Examples

The following examples show how to use org.hibernate.annotations.Immutable. 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
Source File: JavaTypeDescriptorRegistry.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
@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 File: PropertyBinder.java    From lams with 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
Source File: SerializableTypeDescriptor.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@SuppressWarnings({ "unchecked" })
private static <T> MutabilityPlan<T> createMutabilityPlan(Class<T> type) {
	if ( type.isAnnotationPresent( Immutable.class ) ) {
		return ImmutableMutabilityPlan.INSTANCE;
	}
	return (MutabilityPlan<T>) SerializableMutabilityPlan.INSTANCE;
}