
From the image above you can see a column in the MySQL database (table Question) where I have a column that has a default value of ‘Approved’. However if I make a new Question instance, set values on the object but not the status property it persist null in the status column instead of using the default value. Do I need to set the default value in the Java code instead? (Where I persist it)
Yes. When a persistent field of an entity is null, JPA doesn’t ignore it. It sets the column to null in the generated insert/update statements. So you must set it to the default value in Java. The constructor of the entity could be the appropriate place to set such a default value.