我正在使用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。