在Grails中,有没有办法限制枚举枚举的列的大小.在以下示例中,我希望列类型为char(2)
enum FooStatus {
BAR('br'), TAR('tr')
final static String id
}
class Foo {
FooStatus status
static constraints = {
status(inList:FooStatus.values()*.id,size:2..2)
}
}
Run Code Online (Sandbox Code Playgroud)
在导出模式时,inList和size都没有任何效果,列类型保持其默认值(varch(255))如果我定义一个新的UserType,也许我可以这样做.任何的想法 ?
谢谢你
我在Grails中使用Enumeration时遇到问题:我尝试在grails域对象中使用enumeraion
码:
package it.xxx.tools.kanban
import java.util.Date;
class Task {
String name
String description
Priority priority
static belongsTo = [user:User, project:Project]
static constraints = {
name(nullable:false, maxSize:25)
description(nullable:false, maxSize:1500)
priority(nullable:true)
}
}
package it.xxx.tools.kanban;
public enum Priority {
VERY_LOW("Very Low"),
LOW("Low"),
MEDIUM("Medium"),
HIGH("High"),
VERY_HIGH("Very High")
private final String value
Priority(String value){
this.value = value;
}
String toString() {
value
}
String getKey() {
name()
}
static list(){
[VERY_LOW, LOW, MEDIUM, HIGH, VERY_HIGH]
}
}
<tr class="prop">
<td valign="top" class="name">
<label for="priority">Priority:</label> …Run Code Online (Sandbox Code Playgroud)