use of org.hibernate.annotations.TimeZoneStorage in project hibernate-orm by hibernate.
the class BasicValueBinder method prepareCollectionElement.
private void prepareCollectionElement(XProperty attributeXProperty, XClass elementTypeXClass) {
XClass xclass = elementTypeXClass == null && attributeXProperty.isArray() ? attributeXProperty.getElementClass() : elementTypeXClass;
Class<?> javaType = resolveJavaType(xclass);
implicitJavaTypeAccess = typeConfiguration -> javaType;
final Temporal temporalAnn = attributeXProperty.getAnnotation(Temporal.class);
if (temporalAnn != null) {
temporalPrecision = temporalAnn.value();
if (temporalPrecision == null) {
throw new IllegalStateException("No jakarta.persistence.TemporalType defined for @jakarta.persistence.Temporal " + "associated with attribute " + attributeXProperty.getDeclaringClass().getName() + '.' + attributeXProperty.getName());
}
} else {
temporalPrecision = null;
}
if (javaType.isEnum()) {
final Enumerated enumeratedAnn = attributeXProperty.getAnnotation(Enumerated.class);
if (enumeratedAnn != null) {
enumType = enumeratedAnn.value();
if (enumType == null) {
throw new IllegalStateException("jakarta.persistence.EnumType was null on @jakarta.persistence.Enumerated " + " associated with attribute " + attributeXProperty.getDeclaringClass().getName() + '.' + attributeXProperty.getName());
}
}
} else {
enumType = null;
}
final TimeZoneStorage timeZoneStorageAnn = attributeXProperty.getAnnotation(TimeZoneStorage.class);
timeZoneStorageType = timeZoneStorageAnn != null ? timeZoneStorageAnn.value() : null;
normalSupplementalDetails(attributeXProperty);
// layer in support for JPA's approach for specifying a specific Java type for the collection elements...
final ElementCollection elementCollectionAnn = attributeXProperty.getAnnotation(ElementCollection.class);
if (elementCollectionAnn != null && elementCollectionAnn.targetClass() != null && elementCollectionAnn.targetClass() != void.class) {
final Function<TypeConfiguration, BasicJavaType> original = explicitJavaTypeAccess;
explicitJavaTypeAccess = (typeConfiguration) -> {
final BasicJavaType<?> originalResult = original.apply(typeConfiguration);
if (originalResult != null) {
return originalResult;
}
return (BasicJavaType<?>) typeConfiguration.getJavaTypeRegistry().getDescriptor(elementCollectionAnn.targetClass());
};
}
}
Aggregations