How do I set a default value in Hibernate field?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you want a real database default value, use
columnDefinition:Notice that the string in
columnDefinitionis database dependent. Also if you choose this option, you have to usedynamic-insert, soHibernatedoesn’t include columns withnullvalues on insert. Otherwise talking about default is irrelevant.But if you don’t want database default value, but simply a default value in your Java code, just initialize your variable like that –
private Integer myColumn = 100;