簡體   English   中英

Hibernate:如何映射Double的集合?

[英]Hibernate: how to map collection of Double?

如何映射Double值列表

class Person {

    @Id
    private String key;

   @OneToMany
   @Column(name="values")
   private List<Double> values;

我得到這個錯誤

Use of @OneToMany or @ManyToMany targeting an unmapped class: Person.values[java.lang.Double]

嘗試像這樣使用注釋@CollectionOfElements

@CollectionOfElements
   @Column(name="values")
   private List<Double> values;

如果您使用的是3.4,則可以使用。

而且,如果您使用的是Hibernate Annotations 3.5+,則更喜歡使用@ElementCollection注解的JPA 2.0注解:

@ElementCollection
@Column(name="values")
   private List<Double> values;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM