简体   繁体   中英

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)

}

}

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 
.....

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM