1

基準を使用すると、次のエラーが発生します。助けてください。

エラー:

2012-12-02 19:50:43,678 [http-8080-2] ERROR property.BasicPropertyAccessor  - IllegalArgumentException in class: indiaweatherstation.WeatherStation, getter method of property: id
2012-12-02 19:50:43,683 [http-8080-2] ERROR errors.GrailsExceptionResolver  - Exception occurred when processing request: [GET] /IndiaWeatherStation/
Stacktrace follows:
    java.lang.IllegalArgumentException: object is not an instance of declaring class
        at grails.orm.HibernateCriteriaBuilder.invokeMethod(HibernateCriteriaBuilder.java:1163)
        at indiaweatherstation.CrawlerController$_closure1_closure3.doCall(CrawlerController.groovy:140)
        at indiaweatherstation.CrawlerController$_closure1.doCall(CrawlerController.groovy:19)
        at indiaweatherstation.CrawlerController$_closure1.doCall(CrawlerController.groovy)
        at java.lang.Thread.run(Thread.java:662)

探す:

 def awsdata = AWSData.withCriteria {

                        eq("station", station)
                    and {
                    eq("day",dayObject)
                    }
                    }

ドメイン:

class AWSData {

    static hasOne =[station:WeatherStation, day:Day, slp:SLP,
        mslp:MSLP, rain:Rainfall, tempreature:Tempreature, 
        point:DewPoint, windSpeed:WindSpeed, 
        windDir:WindDirection, ptend:PTEND, sshm:SSHM]

    int id
    String tmax
    String tmin
    static constraints = {
        station (blank:true, nullable:true)
        day     (blank:true, nullable:true)
        slp     (blank:true, nullable:true)
        mslp    (blank:true, nullable:true)
        rain  (blank:true, nullable:true)
        tempreature (blank:true, nullable:true)
        point (blank:true, nullable:true)
        windSpeed (blank:true, nullable:true)
        windDir (blank:true, nullable:true)
        ptend (blank:true, nullable:true)
        sshm (blank:true, nullable:true)
        tmax (blank:true, nullable:true)
        tmin (blank:true, nullable:true)


    }
}

class WeatherStation {

    static hasOne= [district:District]
    static hasMany = [AWSData:AWSData, ARGData:ARGData,
        HWSRData:HWSRData, radiationData:RadiationData]
    int id
    String name
    String lat
    String lng

    static constraints = {

        AWSData (blank:true, nullable:true)
        ARGData (blank:true, nullable:true)
        HWSRData (blank:true, nullable:true)
       radiationData (blank:true, nullable:true)
    }
}
4

2 に答える 2

0

その理由は、1つの要素を期待しているので、使用する必要があるためです

def awsdata = AWSData.createCriteria().get {
                    and {
                        eq( "station", station)
                        eq( "day", dayObject )
                    }
                }
于 2012-12-02T16:25:24.543 に答える
0

あなたのeqステートメントは両方とも の中にあるべきではありませんandか?

def awsdata = AWSData.withCriteria {
  and {
    eq( "station", station )
    eq( "day", dayObject )
  }
}
于 2012-12-02T12:11:36.477 に答える