Search code examples
grailsgrails-orm

Grails allow null for double not working


the nullable is not working for lat and lng. Please help.

class Location {
    int id
    String country
    String province
    String city
    double lat 
    double lng 
static mapping = {
    table: 'Locaations'
    country length:100
    province length: 100
    city length: 100
}    
static constraints = {
    province(blank:true, nullable:true)
    city(blank:true, nullable:true)
    lat(blank: true, nullable:true)
    lng (blank:true, nullable:true)

}

}


Solution

  • Primitive double type variable itself can neither be null nor be blank(blank:true is for String only). It has nothing to do with Grails. Use java.lang.Double instead:

    .....
        Double lat 
        Double lng 
    .....