In Hibernate 5.6 I found a dirty way to get the annotated element to which the @Type
was applied by taking a deep dive into the properties provided by DynamicParameterizedType#setParameterValues(Properties parameters)
:
Method tam = JavaXMember.class.getSuperclass().getDeclaredMethod("toAnnotatedElement");
tam.setAccessible(true);
AnnotatedElement field = tam.invoke(properties.get(XPROPERTY));
I then would be able to get the generic type of the attribute by doing something like this:
Type attributeType = ((Field)field).getGenericType();
In Hibernate 6.6, due to modularization, I don’t have access to JavaXMember anymore.
Eg. I want to get hands on the generic type representing EnumSet<Name>
.
@Type(MyDynamicParameterizedType.class)
@Column(nullable = false)
protected EnumSet<Name> names;
Can someone provide me a solution on how to get the java.lang.reflect.Type
of the entity attribute (names
in the example) that is annotated with a dynamic parameterized @Type(...)
implementation?