0

I am stuck with an issue while using Hibernate - JPA.

Issue is I am having an entry which is of type ArrayList. This ArrayList can have any type of values, but limited to some primitive ones + String + Timestamp. In short entries which are not entities, but elementary values.

My question here is what type I should use to store this kind of field in the Entity?

4

1 回答 1

1

@ElementCollection 是您正在寻找的。这使您可以为非实体类(例如 Embeddable 或 Basic)定义映射。

http://en.wikibooks.org/wiki/Java_Persistence/ElementCollection

您还可以使用@CollectionTable 来定义表。

@ElementCollection
@CollectionTable(name = "data" ....)
private List<String> data;
于 2013-11-12T15:59:50.167 回答