【问题标题】:Is there a "collection-type" equivalent annotation in Hibernate?Hibernate 中是否有“集合类型”等效注释?
【发布时间】:2011-06-23 14:36:53
【问题描述】:

在 Hibernate 中,您可以通过在 hibernate xml 映射文件中设置“collection-type”属性来定义自定义集合类型。

我想知道是否有等效的注释。

PS:我尝试使用 @Type 但休眠抱怨:

"Illegal attempt to map a non collection as a @OneToMany, @ManyToMany" ...

所以我假设@Type 仅适用于常规属性。

谢谢!

【问题讨论】:

  • 所以你说的不是例如java.util.List 你有自己的集合类型,但没有实现 Collections 接口之一?
  • @Geziefer,实际上我试图使用 Glazed Lists “EventList” (glazedlists.com/documentation/…) 而不是 List。我早就放弃了这个想法:太多的“副作用”。
  • 哎呀,没注意到你的问题是半年前的。从来没有听说过,但我觉得在 O/R 映射中使用标准构造总是有回报的。

标签: java hibernate java-ee-6


【解决方案1】:

提出这个问题时,没有这样的注释。由于HHH-4417 在版本 4.1.1 中已修复,因此存在org.hibernate.annotations.CollectionType。虽然我不知道它是否适用于提到的 EventList 集合。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-02-06
    • 1970-01-01
    • 2019-01-13
    • 1970-01-01
    • 1970-01-01
    • 2014-09-07
    • 1970-01-01
    相关资源
    最近更新 更多