Case-insensitive unique constraint in Grails
问题 How can I basically carry out a unique constraint on a string data-type field. class User{ String username String Email static hasMany = [roles:Roles] static constraints = { Email(email:true) username(unique:true) } } Is there any simple way to implement username(unique: true) Or must I manually check the database using methods like .findByNameLike ? The username should be unique, but the uniqueness is should be case-insensitive. 回答1: So, if you want to have unique and case insensitive