I can define default value in domain by this way :
class ProcessingPriority {
static constraints = {
}
String processingPriority = "medium"
String toString()
{
retur开发者_JS百科n processingPriority
}
}
If I'm using this in another domain (using one-to-one), processingPriority is not define to "medium" but "null", ex :
class AnnotationForm {
static belongsTo = ProcessingPriority
static constraints = {processingPriority()}
ProcessingPriority processingPriority
...
}
How can I set my class AnnotationForm to define : String processingPriority = "medium" ?
Is there a best way to define default values in relationship 1to1 ?
I am not sure if I understand what you are asking however.
try
class AnnotationForm {
static belongsTo = ProcessingPriority
static constraints = {processingPriority()}
ProcessingPriority processingPriority = new ProcessingPriority();
...
}
This will create the child object with defaults. If it's still null there must be something changing the value.
精彩评论