繁体   English   中英

Hibernate如何在@OneToMany映射中找到集合的泛型类型?

[英]How does Hibernate find the generic type of a collection in a @OneToMany mapping?

给定一个简单的实体关系:

@Entity
public class Single {

  @OneToMany
  public Set<Multiple> multiples;
}

Hibernate如何发现泛型的泛型类型是多个? 使用标准Reflection API无法找到此信息。

我正在查看源代码,但不知道从哪里开始。

但是可能找到使用反射API。 看看Field.getGenericType()

Type type = field.getGenericType();
if (type instanceof ParameterizedType) {
  Type[] genericArguments = ((ParameterizedType) type).getActualTypeArguments();
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM