如何将枚举类型的 mysql 字段映射到 grails 域类?
我正在使用带有 grails v.2.0.3 的现有(旧版)mySQL 数据库。我收到错误列类型的错误:
failed; nested exception is org.hibernate.HibernateException: Wrong column type in
facilities.ost_fac_syslog for column log_type. Found: enum, expected: varchar(255)
SQL字段定义为:
mysql> describe ost_fac_syslog;
+------------+---------------------------------+------+-----+--------------------
| Field | Type | Null | Key | Default
+------------+---------------------------------+------+-----+----------------------+
| log_id | int(11) unsigned | NO | PRI | NULL auto_increment |
| log_type | enum('Debug','Warning','Error') | NO | MUL | NULL | |
我的域类是:
class OstFacSyslog {
static mapping = {
table 'ost_fac_syslog'
version false
id column: 'log_id', name:'logId'
logType column: 'log_type', type: 'enum', name: 'logType'
}
Integer logId
LogType logType
enum LogType {
Debug('Debug'), Warning('Warning'), Error('Error')
private final String toString
LogType(String toString) {this.toString = toString}
String getName() {name()}
String toString() {toString}
}
}
谢谢,我很感激任何帮助。