Here is my JPA2 / Hibernate definition:
@Column(nullable = false)
private boolean enabled;
In MySql this column is resolved to a bit(1) datatype – which does not work for me. For legacy issues I need to map the boolean to a tinyint not to a bit. But I do not see a possibility to change the default datatype. Is there any?
Try the
NumericBooleanType. For some reason this doesn’t have a declared short type name so you’d have to use:This does map to an INTEGER type but it will probably work fine with a TINYINT.
UPDATE:
org.hibernate.type.NumericBooleanTypeDoes not work with TINYINT in some RDBMS. Switch the database column type to INTEGER. Or use a different Java @Type value, or columnDefinition, as appropriate.In this example, Dude’s answer of
@Column(nullable = false, columnDefinition = "TINYINT(1)")would work without any database changes.