2012-12-02 16 views
0

기준을 사용할 때 다음 오류가 발생합니다. Pls 도움.Grails 객체가 클래스 선언의 인스턴스가 아닙니다.

오류 :

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) 
    } 
} 

답변

0

이유는 I 이렇게 발생 예외 [indiaweatherstation.CrawlerController] 컨트롤러

def awsdata = AWSData.createCriteria().get { 
        and { 
         eq("station", station) 
         eq("day", dayObject) 
        } 
       } 
0

eq 문이 모두 and 안에 안?

def awsdata = AWSData.withCriteria { 
    and { 
    eq("station", station) 
    eq("day", dayObject) 
    } 
} 
+0

여전히 동일한 오류 실행 작용 [인덱스]를 사용해야하는 하나 개의 요소를 기대 야이다는 IllegalArgumentException가 indiaweatherstation의 게터를 호출 발생. WeatherStation.id – user903772

+1

@ user903772 궁금한데, 왜'id' 필드를'int'로 정의 했습니까? Grails는 id를 자동으로 제공해야합니다 ... –

+0

id를 정의하면 int가 아닌 길이 여야합니다. – erturne

관련 문제