Grails- Unique constraint

Posted by WaZ on Stack Overflow See other posts from Stack Overflow or by WaZ
Published on 2010-03-29T12:30:22Z Indexed on 2010/03/29 12:33 UTC
Read the original article Hit count: 438

Filed under:

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 I will have to manually check the database by the in-built methods like .findByNameLike.

My need is that username should be unique and should be case insensitive

© Stack Overflow or respective owner

Related posts about grails