开发者

How to resolve No data type for node error in hibernate

I have table vehicle ,i have written quer开发者_JS百科y 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:''}"
    }


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.


Make sure you have field specified by that name in Entity

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜