凹槽/圣杯映射错误 'field list'中未知列'class'



最近我开始使用groovy和grails,但我有以下错误:

由:com.mysql.jdbc.exceptions.jdbc4.mysqlsyntaxerrorexception:
未知列" class"在"字段列表"中 在com.mysql.jdbc.util.handlenewinstance(util.java:404) 在com.mysql.jdbc.util.getinstance(util.java:387) 在com.mysql.jdbc.sqlerror.createsqlexception(sqlerror.java:942)

但是我的实体和母亲没有班级属性看到没有类字段,但在mysql上以某种方式插入它的现在

class Freight extends Base {
String codeBegin
String codeEnd
BigDecimal weight
BigDecimal value
BigDecimal minValue
FreightRange range
Integer time
FreightType type
String name
Integer leadTime
BigDecimal realFreightValue
String realFreightName
FreightType realFreightType
Manufacturer manufacturer
static embedded = ['range']
static transients = ['type', 'name', 'leadTime', 'realFreightValue', 'realFreightName', 'realFreightType', 'manufacturer']
static belongsTo = [partnerFreightType: PartnerFreightType]
static mapping = {
    version false
}
static constraints = {
    codeBegin nullable: true, blank: true, validator: Freight.rangeValidator
    codeEnd nullable: true, blank: true, validator: Freight.rangeValidator
    weight nullable: false, min: BigDecimal.valueOf(0.001)
    value nullable: false, min: BigDecimal.valueOf(0), max: BigDecimal.valueOf(9999.99)
    minValue nullable: false, min: BigDecimal.valueOf(0)
    range nullable: true
    time nullable: true
}
static rangeValidator = { val, obj ->
    if (obj.codeBegin?.replace('-', '')?.toInteger() > obj.codeEnd?.replace('-', '')?.toInteger())
        return 'freight.error.range'
}
String getHash() {
    (this.partnerFreightType + this.type + this.value).encodeAsMD5()
}

void useRange(FreightRange range) {
    this.range = range
    def codes = range.codes()
    this.codeBegin = codes.min
    this.codeEnd = codes.max
}

}

由于您有类层次结构,因此必须有(称为歧视者)才能知道从表中获取行时可以实例化的类。

来自GORM文档:"在数据库级别的Gorm默认使用clast-lierearky列映射,使用歧视列,称为类,因此父类(content)及其子类(Blogentry,book等)共享同一表格。"

相关内容

最新更新