How to set a default entity property value with Hibernate

后端 未结 17 2335
一整个雨季
一整个雨季 2020-11-28 02:53

How do I set a default value in Hibernate field?

17条回答
  •  Happy的楠姐
    2020-11-28 03:20

    Working with Oracle, I was trying to insert a default value for an Enum

    I found the following to work the best.

    @Column(nullable = false)
    @Enumerated(EnumType.STRING)
    private EnumType myProperty = EnumType.DEFAULT_VALUE;
    

提交回复
热议问题