I am using postgres database. After upgading to grails 2.4.3 I get database changeset of this type for all boolean fields:
changeSet(author: "me(generated)", id: "1383573084784-1") {
addColumn(tableName: "chapter") {
column(defaultValue: true, name: "is_framable", type: "boolean") {
constraints(nullable: "false")
}
}
}
isFramable
is a boolean
field in the domain class Chapter
. Even after running this migration it's generated everytime by dbm-gorm-diff
I noticed that in older versions of grails there used to be bool
instead of boolean
in the changesets
I am using hibernate version 4.3.5.5
My workaround for that:
Config.groovy
grails.gorm.default.mapping = {
"user-type" type: my.hibernate.type.BooleanBitType, class: boolean
"user-type" type: my.hibernate.type.BooleanBitType, class: Boolean
}
BooleanBitType.java
import my.hibernate.type.descriptor.BooleanBitTypeDescriptor;
import org.hibernate.type.descriptor.java.BooleanTypeDescriptor;
import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;
public class BooleanBitType extends org.hibernate.type.BooleanType {
public static final BooleanBitType INSTANCE = new BooleanBitType();
public BooleanBitType() {
this(BooleanBitTypeDescriptor.INSTANCE, BooleanTypeDescriptor.INSTANCE);
}
protected BooleanBitType(SqlTypeDescriptor sqlTypeDescriptor, BooleanTypeDescriptor javaTypeDescriptor) {
super(sqlTypeDescriptor, javaTypeDescriptor);
}
}
BooleanBitTypeDescriptor.java
public class BooleanBitTypeDescriptor extends org.hibernate.type.descriptor.sql.BooleanTypeDescriptor {
public static final BooleanBitTypeDescriptor INSTANCE = new BooleanBitTypeDescriptor();
public BooleanBitTypeDescriptor() {
super();
}
public int getSqlType() {
return Types.BIT;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With