I have an attribute
private boolean include;
I would like to set its default value to true, so that in the database it must display True from d
If you have defined default values in your database, you can choose the column annotation, and as parameter you use insertable = false
, in this way when inserting a value it will choose the one that you marked by default in the database. Example:
In MySQL I have a person table with a status attribute of boolean type and it has by default the value true.
In your java class it would look like this:
//....
public class Person implements Serializable {
//.....
@Column(insertable = false)
private Boolean status;
//...
}
You can have more information about the column annotation HERE, it is well explained and it helped me a lot.