Mapping 如何使用JPA2映射实体中的枚举集(或枚举列表)

Mapping 如何使用JPA2映射实体中的枚举集(或枚举列表),mapping,entity,enumset,Mapping,Entity,Enumset,我有一个人: @Entity @Table(schema="", name="PERSON") public class Person { List<PaymentType> paymentTypesList; //some other fields //getters and setters and other logic } 如何持久化Person及其枚举列表(在此列表中,我必须放置数量可变的枚举,可能有一个,也可能有两个或全部) 我在Post

我有一个人:

@Entity
@Table(schema="", name="PERSON")
public class Person {
    List<PaymentType> paymentTypesList;
    //some other fields     
    //getters and setters and other logic
}
如何持久化Person及其枚举列表(在此列表中,我必须放置数量可变的枚举,可能有一个,也可能有两个或全部)


我在Postgres中使用Spring,实体是使用JPA注释创建的,并使用Hibernate进行管理。

问问你自己,
PaymentType
s是否会随时间而改变

我将创建一个带有一个name属性的
@Entity PaymentType
,并在
PaymentType
Person
之间创建一个
@Many2Many

另一种方法:
@ElementCollection

public enum PaymentType {
    FIXED, CO_FINANCED, DETERMINED;
}