How to set a default entity property value with Hibernate

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

How do I set a default value in Hibernate field?

17条回答
  •  眼角桃花
    2020-11-28 03:15

    The above suggestion works, but only if the annotation is used on the getter method. If the annotations is used where the member is declared, nothing will happen.

    public String getStringValue(){
         return (this.stringValue == null) ? "Default" : stringValue;
    }
    

提交回复
热议问题