gpt4 book ai didi

grails - Groovy/Grails映射错误 'class'中的未知列 'field list'

转载 作者:行者123 更新时间:2023-12-02 15:46:56 24 4
gpt4 key购买 nike

最近,我开始使用Groovy和Grails,但是出现以下错误:

Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:
Unknown column 'class' in 'field list' at com.mysql.jdbc.Util.handleNewInstance(Util.java:404) at com.mysql.jdbc.Util.getInstance(Util.java:387) at 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
}

}

最佳答案

由于您具有类层次结构,因此必须有一种方法(称为鉴别器),ORM才能从表中获取行时知道要实例化的类。

从GORM文档中:“默认情况下,GORM在数据库级别使用按表的逐级映射和一个名为class的区分列,因此父类(内容)及其子类(BlogEntry,Book等)共享同一张表。”

http://gorm.grails.org/6.0.x/hibernate/manual/#inheritanceInGORM

关于grails - Groovy/Grails映射错误 'class'中的未知列 'field list',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45923954/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com