@Type annotation is an Hibernate annotation.
In full JPA2 (with Hibernate 3.6+), the way to map a Boolean field to a TINYINT(1) SQL type instead of BIT(1), is to use the columnDefinition attribute.
@Column(nullable = false, columnDefinition = "TINYINT(1)")
private boolean enabled;
nb: length attribute seems to have no effect in this case, then we use (1) syntax.
With Hibernate 4.0+, this kind of syntax can cause an runtime error like this :
Wrong column type Found: bit, expected: TINYINT(1)
It seems that in this case, your only way is to use tinyInt1isBit=false in the MySQL datasource connection string like this :
jdbc:mysql://server_host:3306/database?tinyInt1isBit=false
By the way, you can now use the length attribute like this :
@Column(nullable = false, columnDefinition = "TINYINT", length = 1)
private boolean enabled;
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…