JPA map collection of Enums

后端 未结 6 705
滥情空心
滥情空心 2020-11-27 12:46

Is there a way in JPA to map a collection of Enums within the Entity class? Or the only solution is to wrap Enum with another domain class and use it to map the collection?<

6条回答
  •  猫巷女王i
    2020-11-27 13:12

    I was able to accomplish this in this simple way:

    @ElementCollection(fetch = FetchType.EAGER)
    Collection interests;
    

    Eager loading is required in order to avoid lazy loading inizializing error as explained here.

提交回复
热议问题