gpt4 book ai didi

grails - 如何解决休眠中节点错误的无数据类型

转载 作者:行者123 更新时间:2023-12-02 14:21:24 27 4
gpt4 key购买 nike

我有 table 车,我写了如下查询

Vehicle.executeQuery("从车辆中选择音频系统")
但我收到一个错误

ERROR groovy.grails.web.errors.GrailsExceptionResolver ### No data type for node: org.hibernate.hql.ast.tree.IdentNode -[IDENT] IdentNode: 'audio_system' {originalText=audio_system}

java.lang.IllegalStateException: No data type for node: org.hibernate.hql.ast.tree.IdentNode -[IDENT] IdentNode: 'audio_system' {originalText=audio_system}



车辆类源代码如下
class Vehicle {


String vehicleSticker
String regNumber //plate
String chasisNumber
String engineNumber
Integer yearOfManufacture
Date purchasedOn

Boolean audioSystem
Boolean videoSystem
Boolean mobileCharger
Boolean laptopCharger

//Vehicle compliance
Date pucExpiry
Date pucTestingOn
Date taxTokenIssueDate
Date taxTokenExpiryDate
Date insuranceIssueDate
Date insuranceExpiryDate
Date permitIssueDate
Date permitExpiryDate
Date fitnessCertificateIssueDate
Date fitnessCertificateExpiryDate
Double odoReadingWhenServiceDone
Double dueOddReading

VendorRole vendor

VehicleType vehicleType
//RegistrationCertificate registrationCertificate

static mapping = {
//registrationCertificate(cascade:'all')

}

static constraints = {
yearOfManufacture(nullable:true)
regNumber(nullable:false,unique: true)
chasisNumber(blank:true)
engineNumber(blank:true)
purchasedOn(nullable:true)
taxTokenIssueDate(nullable:true)
taxTokenExpiryDate(nullable:true)

insuranceIssueDate(nullable:true)
insuranceExpiryDate(nullable:true)
permitIssueDate(nullable:true)
permitExpiryDate(nullable:true)
fitnessCertificateIssueDate(nullable:true)
fitnessCertificateExpiryDate(nullable:true)
odoReadingWhenServiceDone(nullable:true)

dueOddReading(nullable:true)
pucExpiry(nullable:true)
pucTestingOn(nullable:true)

vendor(nullable:true)


}

public String toString() {
"${vehicleSticker} ${regNumber?'| '+ regNumber:''}"
}

最佳答案

那应该是

Vehicle.executeQuery("select audioSystem from Vehicle ")

这是一个 HQL 查询,您使用类名和字段名,而不是表名和列名。

关于grails - 如何解决休眠中节点错误的无数据类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5974121/

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