Thursday, 15 January 2015

hibernate - Unneccessary database changeSet related to boolean after grails 2.4.3 upgrade -



hibernate - Unneccessary database changeSet related to boolean after grails 2.4.3 upgrade -

i using postgres database. after upgading grails 2.4.3 database changeset of type boolean fields:

changeset(author: "me(generated)", id: "1383573084784-1") { addcolumn(tablename: "chapter") { column(defaultvalue: true, name: "is_framable", type: "boolean") { constraints(nullable: "false") } } }

isframable boolean field in domain class chapter. after running migration it's generated everytime dbm-gorm-diff

i noticed in older versions of grails there used bool instead of boolean in changesets

i using hibernate version 4.3.5.5

my workaround 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() { homecoming types.bit; } }

hibernate postgresql grails gorm

No comments:

Post a Comment