How to persist a List of Strings in Hibernate?

后端 未结 2 1717
半阙折子戏
半阙折子戏 2020-12-08 06:11

I seem to have problems with mapping a List in Hibernate. In our project there a class Card with contains a class Answer with Answer c

2条回答
  •  心在旅途
    2020-12-08 07:00

    Use @ElementCollection:

    @ElementCollection
    @CollectionTable(name="Nicknames", joinColumns=@JoinColumn(name="user_id"))
    @Column(name="nickname")
    public List getNicknames() { ... } 
    

    Source: 7.2.3. Collections of basic types and embeddable objects

提交回复
热议问题