I have a lot of Boolean
fields in my class and I'm storing them in TINYINT(1)
It's not a problem putting the annotation once, but I have a lot of them and this code looks a bit messy:
@Column(nullable = false, columnDefinition = "TINYINT(1)")
private Boolean isRescheduled;
@Column(nullable = false, columnDefinition = "TINYINT(1)")
private Boolean isCancelled;
@Column(nullable = false, columnDefinition = "TINYINT(1)")
private Boolean isFullDay;
Is it possible to specify @Column
for Boolean
once?
You need your own Dialect
.
Extend a dialect for your database, for example MyDialect extends MySQL5Dialect
.
In the constructor of MyDialect
override a type
registerColumnType(Types.BOOLEAN, "tinyint(1)");
Use MyDialect
in the hibernate.cfg.xml
or hibernate.properties
.