I have a domain class:
class ProgramArea {
String programCd
String programArea
String description
static constraints = {
programCd(nullable: false, unique: true)
programArea(nullable: false, blank: false, unique: true)
description(nullable: true, blank: true, maxSize: 50)
}
}
In the database, I want the programCd field to be a ‘NOT NULL’ field. However, this is not user entered field. I have code in the controller to generate programCd. However, when I try to insert new data, I get a validation error saying programCd cannot be null.
If I modify the constraint for programCd as ‘nullable: true’, everything works fine. Can someone please let me know if there is a workaround for this?