Grails 插件数据库迁移使用哈希图添加域对象

Grails plugin databasemigration add domain object with hashmap

我想将此域对象添加到我的应用程序中:

class DatatableListviewAvlColumns {

static constraints = {
}

static hasMany = [availableListviewColumns:  ListviewColumnDefinition]


static mapping = {
    availableListviewColumns cascade: 'all-delete-orphan'
}


Map<String, ListviewColumnDefinition> availableListviewColumns = new HashMap<>()

String datatableName
}

在我的 changelog.groovy 中,我添加了这个:

 changeSet(author: "pm", id: "datatable_listview_avl_columns") {
    createTable(tableName: "datatable_listview_avl_columns") {
        column(name: "id", type: "BIGINT") {
            constraints(nullable: "false")
        }

        column(name: "version", type: "BIGINT") {
            constraints(nullable: "false")
        }

        column(name: "datatable_name", type: "TEXT") {
            constraints(nullable: "false")
        }
    }
}

changeSet(author: "pm", id: "datatable_listview_avl_columns_definition") {
    createTable(tableName: "datatable_listview_avl_columns_available_listview_columns") {
        column(name: "datatable_listview_avl_columns_id", type: "BIGINT") {
            constraints(nullable: "false")
        }
        column(name: "listview_column_definition_id", type: "BIGINT")

        column(name: "available_listview_columns_idx", type: "STRING")
    }
}

当我启动应用程序时,我得到这个异常:

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'methodValidationPostProcessor' defined in class path resource ...... is org.hibernate.MappingException: Missing type or column for column[available_listview_columns_listview_column_definition] on domain[lomnido.DatatableListviewAvlColumns] referencing[com.lomnido.view.ListviewColumnDefinition]

对于这种情况,changelog.groovy 中的正确条目是什么? 我以前从未将 Hashmap 与对象一起使用,但我认为这应该是可能的?还是我错了?

我发现了我的错误。 ListViewColumndDefinition 不是域对象。所以这行不通。