【问题标题】:How to store a Collection of Dates in Hibernate如何在 Hibernate 中存储日期集合
【发布时间】:2011-09-07 11:15:08
【问题描述】:

如果我在 JPA2 @Entity 中有以下字段:

List<Date> associatedDates;

如何让 JPA2 持久化该字段?

@OneToMany 似乎不起作用。

JPA2 的@ElementCollection 是最好的选择吗?如果是,我是否需要使用带有@Entity 注释的包装器?

this 示例中的serviceHistory 集合使用了这种方法,但是ServiceVisit 类封装了更多信息——我真的只需要存储一个时间点的集合。

【问题讨论】:

    标签: hibernate jpa jpa-2.0


    【解决方案1】:

    Hibernate 参考指南包含您需要了解的有关 mapping a collection of elements 的所有信息,因为 Date 不是映射实体。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-09-28
      • 2016-08-07
      • 2019-12-16
      • 1970-01-01
      • 1970-01-01
      • 2013-08-10
      • 2015-12-21
      • 1970-01-01
      相关资源
      最近更新 更多