簡體   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