Given a simple entity relationship:
@Entity
public class Single {
@OneToMany
public Set<Multiple> multiples;
}
How does Hibernate find out that the generic type of multiples is Multiple? This information is impossible to find with the standard Reflection API.
I'm looking through the source code, but don't really know where to start.
But it is possible to find out using reflection API. Take a look at Field.getGenericType():
Type type = field.getGenericType();
if (type instanceof ParameterizedType) {
Type[] genericArguments = ((ParameterizedType) type).getActualTypeArguments();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With