mysql 设置约束长度_Grails / MySQL字段长度约束

我正在使用Grails 1.3.7和MySQL 5.1。 s> 5.5。我有一个类,像这样定义一个字符串属性:

class Topic {

String name;

User owner;

// other fields

static constraints = {

name(blank: false, maxSize: 1024, unique: ['owner'])

}

}这对内存数据库工作正常,但是当我部署WAR文件时,出现此错误:

12/06/07 17:09:48 ERROR hbm2ddl.SchemaUpdate: Unsuccessful: create table topic (id bigint not null auto_increment, version bigint not null, date_created datetime not null, description longtext, name longtext not null, owner_id bigint not null, primary key (id), unique (owner_id, name))

12/06/07 17:09:48 ERROR hbm2ddl.SchemaUpdate: BLOB/TEXT column 'name' used in key specification without a key length如果我将maxSize规范更改为255,则一切正常。

我对文档的阅读是,MySQL在默认情况下无法计算出密钥长度来执行唯一性约束;为什么grails不会为此目的传递maxSize值?

更新:2012年6月8日

这里是我正在使用的hibernate规范:

hibernate {

cache.use_second_level_cache=true

cache.use_query_cache=true

cache.provider_class='net.sf.ehcache.hibernate.EhCacheProvider'

}我在使用MySQL 5.5的mysql-connector-java-5.1.7-bin.jar库时使用了com.mysql.jdbc.Driver。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值