grails - Gorm : how to set datatype of a value in a Map

标签 grails map grails-orm

在我的域对象中,我有一张 map :

Map<String, String> stuff

GORM 自动创建一个表,其中键和值是 varchar(255) .

我需要值是 长文本 反而。我怎么做这件事?

另外,是否有不涉及使用休眠配置的解决方法?

最佳答案

我认为您可以在域类的映射闭包中声明此设置。

约束字符串字段,使其 MySQL 列类型为 TEXT:

static mapping = {
   myTextField type: 'text'
}

也许这可以帮助您:Grails 指南 (5.5.2.1 Table and Column Names)

关于grails - Gorm : how to set datatype of a value in a Map,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5658327/

相关文章:

grails - Grails 中 findAll、getAll 和 list 的区别

grails - 如何在Grails项目中包含Groovy

grails - LDAP:错误代码49-登录时无效的凭证

grails - 从Grails 2.3.2中删除了generate- *命令吗?

grails - Grails:在 Controller 中动态更改域的约束

c++ - 访问 boost fusion map 字段名称

Java 泛型 : Sort Map by Value

scala - 如何在Scala中将对象列表转换为两个字段的映射

grails - 使用 grails criteria api 定义 OR 条件

Grails编辑工作异常更新数据库的值分配