Reputation: 7602
I have table vehicle ,i have written query as below
Vehicle.executeQuery("select audio_system from Vehicle ") but i am getting an error
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}
Source code of vehicle class as follows
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:''}"
}
Upvotes: 1
Views: 10364
Reputation: 125
Make sure you have field specified by that name in Entity
Upvotes: 0
Reputation: 75681
That should be
Vehicle.executeQuery("select audioSystem from Vehicle ")
This is an HQL query, and you use class names and field names, not table names and column names.
Upvotes: 4