映射打破了我的域类

时间:2013-12-19 20:24:41

标签: grails mapping gorm

当我将以下映射添加到我的域类时,我收到错误。有人能帮助我看看我在这里做错了吗?

域类

package sample

class Todo {


    String name
    String note
    Date dateCreated
    Date lastUpdated
    Date dueDate
    Date lastModifiedDate
    Date completedDate
    String priority
    String status = "Started"
    User owner
    Category category

    static belongsTo = [User, Category]

    static constraints = {
        name (blank:false)
        priority()
        status()
        note (maxSize:1000, nullable:true)
        completedDate(nullable:true)
        dueDate(nullable:true)
    }

    String toString() {
        name
    }

}

我要添加的映射

static mapping = {
    table 'todo-tbl'

    columns {
        name column: 'name-str'
        note column: 'note-str'
    }
    cache true
}

添加映射时出现的错误

  

错误500:内部服务器错误URI / sample / todo / list类   org.h2.jdbc.JdbcSQLException未找到消息表“TODO”; SQL   声明:选择this_.id为id72_0_,this_.version为version72_0_,   this_.category_id为category3_72_0_,this_.completed_date为   completed4_72_0_,this_.date_created as date5_72_0_,this_.due_date as   due6_72_0_,this_.last_modified_date as last7_72_0_,   this_.last_updated为last8_72_0_,this_.name-str为name9_72_0_,   this_.note-str为note10_72_0_,this_.owner_id为owner11_72_0_,   this_.priority为priority72_0_,this_.status为status72_0_ from   todo-tbl this_ limit? [42102-164]

1 个答案:

答案 0 :(得分:0)

我解决了这个问题。显然在表名中使用连字符是一个很大的禁忌。这使得表停止在DB中创建。

已更改

table "todo-tbl"

table "todoTbl