2011-05-12 33 views
1

我已經表車輛,我已經寫了查詢,如下如何解決節點錯誤沒有數據類型在Hibernate中

Vehicle.executeQuery(「從車輛選擇audio_system」) 但我得到一個錯誤

ERROR groovy.grails.web.errors.GrailsExceptionResolver ###對於節點沒有任何數據類型:org.hibernate.hql.ast.tree.IdentNode - [IDENT] IdentNode: 'audio_system'{originalText = audio_system}

java.lang.IllegalStateException:沒有數據類型爲no DE: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:''}" 
    } 
+0

您能否提供客戶端和車輛的完整源代碼? – 2011-05-12 06:42:15

+0

我編輯了這個問題。 – n92 2011-05-12 06:49:55

+0

即使當我嘗試獲取除id以外的任何字段我都會收到錯誤 – n92 2011-05-12 06:53:17

回答

4

應是

Vehicle.executeQuery("select audioSystem from Vehicle ") 

這是一個HQL查詢,並且您使用類名稱和字段名稱,而不是表名稱和列名稱。

0

確保您在實體中具有該名稱指定的字段

相關問題