我在 oracle 数据库中有一个 Char 字段。可能的值为“S”和“N”
如何将值映射到 Grails 域对象中定义的布尔字段?“S”值为真,“N”值为假。
谢谢!
我在 oracle 数据库中有一个 Char 字段。可能的值为“S”和“N”
如何将值映射到 Grails 域对象中定义的布尔字段?“S”值为真,“N”值为假。
谢谢!
使用“beforeInsert”来处理转换。
def beforeInsert() {
boolField = (boolField=='S')?true:false
}
在 Grails 2.5.3 中
对于“Y”值为真,“N”值为假。
static mapping = {
boolField column: 'BOOLEAN_FLAG'
boolField type: 'yes_no'
}
对于 1 值为真,0 值为假。
static mapping = {
boolField column: 'BOOLEAN_FLAG'
boolField type: 'org.hibernate.type.NumericBooleanType'
}