oracle10ggrails-ormgrails-2.3

Mapping CHAR oracle type to Boolean in Gorm


I've a Char field in the oracle database. The possible values are "S" and "N"

How can I map the values to a boolean field defined in a Grails Domain Object? The "S" value is true, and the "N" value is false.

Thank you!


Solution

  • In Grails 2.5.3

    For The "Y" value is true, and the "N" value is false.

    static mapping = {
        boolField column: 'BOOLEAN_FLAG'
        boolField type: 'yes_no'
    }
    

    For The 1 value is true, and the 0 value is false.

    static mapping = {
        boolField column: 'BOOLEAN_FLAG'
        boolField type: 'org.hibernate.type.NumericBooleanType'
    }