I’m subclassing EnumJavaTypeDescriptor (i’m want to get the enum java.util.Month to start at 1 when persisted, so that JANUARY -> 1, …, DECEMBER -> 12) and the two methods toOrdinal and fromOrdinaldo not use the Type T of the class declaration (EnumJavaTypeDescriptor<T extends Enum>) but rather redefine their own type : public <E extends Enum> E fromOrdinal(Integer relationalForm) {
Is there a reason for that ?
(It do not prevent me from doing what i want, but it requires more typecasting that seems necessary)
It’s not clear what you are asking. You can create a new custom Type that saves the java.time.Month starting from 1 instead of 0, and you can achieve that via the EnumJavaTypeDescriptor.
Just use Month.of(int month) instead of getJavaType().getEnumConstants()[ relationalForm ] and Month.getValue instead of domainForm.ordinal().
You should contribute the new Type to the hibernate-types open-source project as it supports custom types for Year and YearMonth.