use of org.hibernate.annotations.Immutable in project hibernate-orm by hibernate.
the class BasicValueBinder method normalMutabilityDetails.
private void normalMutabilityDetails(XProperty attributeXProperty) {
explicitMutabilityAccess = typeConfiguration -> {
final Mutability mutabilityAnn = findAnnotation(attributeXProperty, Mutability.class);
if (mutabilityAnn != null) {
final Class<? extends MutabilityPlan<?>> mutability = normalizeMutability(mutabilityAnn.value());
if (mutability != null) {
return getManagedBeanRegistry().getBean(mutability).getBeanInstance();
}
}
final Immutable immutableAnn = attributeXProperty.getAnnotation(Immutable.class);
if (immutableAnn != null) {
return ImmutableMutabilityPlan.instance();
}
// see if the value's type Class is annotated `@Immutable`
if (implicitJavaTypeAccess != null) {
final Class<?> attributeType = ReflectHelper.getClass(implicitJavaTypeAccess.apply(typeConfiguration));
if (attributeType != null) {
if (attributeType.isAnnotationPresent(Immutable.class)) {
return ImmutableMutabilityPlan.instance();
}
}
}
// if the value is converted, see if the converter Class is annotated `@Immutable`
if (converterDescriptor != null) {
final Mutability converterMutabilityAnn = converterDescriptor.getAttributeConverterClass().getAnnotation(Mutability.class);
if (converterMutabilityAnn != null) {
final ManagedBean<? extends MutabilityPlan<?>> jtdBean = getManagedBeanRegistry().getBean(converterMutabilityAnn.value());
return jtdBean.getBeanInstance();
}
if (converterDescriptor.getAttributeConverterClass().isAnnotationPresent(Immutable.class)) {
return ImmutableMutabilityPlan.instance();
}
}
final Class<? extends UserType<?>> customTypeImpl = Kind.ATTRIBUTE.mappingAccess.customType(attributeXProperty);
if (customTypeImpl != null) {
if (customTypeImpl.isAnnotationPresent(Immutable.class)) {
return ImmutableMutabilityPlan.instance();
}
}
// generally, this will trigger usage of the `JavaType#getMutabilityPlan`
return null;
};
}
Aggregations