I have a basic SpringBoot/Hibernate application that deals with a database. I have a column in an Oracle table that represents a boolean value. At the database level, it is represented this way -
P_IND CHAR(1 BYTE) DEFAULT 'N' NOT NULL
At the entity level, I am mapping it this way -
@Column(name = "P_IND")
@Type(type = "yes_no")
private boolean ind;
When creating new records, the default needed to be an 'N' and this worked as expected. Now the default needs to be true
('Y' in the database). I could do it this way
a) private boolean ind = true;
or add this annotation
b) @ColumnDefault("true")
- Isn't a) more advantageous in that you could create/persist entities with both true/false values?
- Would b) allow you to create both (
ind
is a primitive boolean) and if so, is the annotation a better way of doing it?