Mapping enum to string in hibernate

前端 未结 2 1503
暗喜
暗喜 2021-02-03 16:23

I\'ve got a Category Hibernate model:

@Entity
@Table(name = \"category\")
public class Category {

    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
             


        
2条回答
  •  有刺的猬
    2021-02-03 17:00

    Yes, is possible. It should be:

    @Enumerated(EnumType.STRING)
    @Column(name = "category_type")
    private CategoryType categoryType;
    

提交回复
热议问题