3

Grails2.0.4-インリスト制約と動的ファインダーを使用した動的スキャフォールディングの使用。

ドメインオブジェクトのinList制約で動的ファインダーを使用しようとしています。アプリケーションがアクティブなときにrun-appを介してサンプル2=Aidy.findAll()*。codeに制約を変更すると、ブートストラップされたサンプルデータからオブジェクトフォームにドロップダウンが作成され、美しく機能します。ただし、その後のgrails run-appを使用したアプリケーションのブートストラップは、MissingMethodExceptionで失敗します。

//1- aidyear(blank:false, maxSize:4, inList:{ [] << '0203' << '0304' << '0405' << '0506'}())
//2- aidyear(blank:false, maxSize:4, inList:{ Aidy.findAll()*.code}())

ドメインのinlist制約でfindAllを使用するのは悪い考えですか?何か提案/推奨事項はありますか?

省略されたエラーは

$ grails run-app
| Running Grails application
| Error 2012-11-09 12:54:16,589 [pool-5-thread-1] ERROR context.GrailsContextLoader  - Error executing bootstraps: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.codehaus.groovy.runtime.InvokerInvocationException: groovy.lang.MissingMethodException: No signature of method: edu.uvm.Aidy.findAll() is applicable for argument types: () values: []
Possible solutions: findAll(), findAll(), findAll(groovy.lang.Closure), findAll(java.lang.Object), findAll(java.lang.String), findAll(groovy.lang.Closure)
Message: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.codehaus.groovy.runtime.InvokerInvocationException: groovy.lang.MissingMethodException: No signature of method: edu.uvm.Aidy.findAll() is applicable for argument types: () values: []
Possible solutions: findAll(), findAll(), findAll(groovy.lang.Closure), findAll(java.lang.Object), findAll(java.lang.String), findAll(groovy.lang.Closure)
   Line | Method
->> 303 | innerRun in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   138 | run      in java.util.concurrent.FutureTask
|   886 | runTask  in java.util.concurrent.ThreadPoolExecutor$Worker
|   908 | run      in     ''
^   680 | run . .  in java.lang.Thread

Caused by BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.codehaus.groovy.runtime.InvokerInvocationException: groovy.lang.MissingMethodException: No signature of method: edu.uvm.Aidy.findAll() is applicable for argument types: () values: []
Possible solutions: findAll(), findAll(), findAll(groovy.lang.Closure), findAll(java.lang.Object), findAll(java.lang.String), findAll(groovy.lang.Closure)
->> 303 | innerRun in java.util.concurrent.FutureTask$Sync
....
....
...

https://github.com/mlmclaug/scaffold_inlist.gitに簡単なサンプルプロジェクト がありますが、これは次の2つのドメインオブジェクト、コントローラー、およびbootstrap.groovyです。

package edu.uvm
class Aidy {
    String code
    String desc
    Date startDate
    Date endDate
    String statusInd

    static constraints = {
        code(unique:true,blank:false, maxSize:4)
        desc(blank:false, maxSize:30)
        startDate(blank:false)
        endDate(blank:false)
        statusInd(blank:false, inList:["A","I"])
    }

}

package edu.uvm
class TreqMap {
        String aidyear
        String treq
        Integer seqno

        static constraints = {
            aidyear(blank:false, maxSize:4, inList:{ [] << '0203' << '0304' << '0405' << '0506'}())
            //aidyear(blank:false, maxSize:4, inList:{ Aidy.findAll()*.code}())
            treq(blank:false, maxSize:6, inList:["BNOTE","SCERT","PERKIN","PNOTE","LNOTE","SNOTE"])
            seqno(blank:true, range:0..99)
       }
}

package edu.uvm
class TreqMapController {
    def scaffold = edu.uvm.TreqMap
}

import edu.uvm.Aidy
class BootStrap {

    def init = { servletContext ->
        new Aidy(code:'0910', desc:'July 2009 - June 2010', startDate:'07/01/2009', endDate:'06/30/2010', statusInd:'A').save(failOnError:true)
        new Aidy(code:'1011', desc:'July 2010 - June 2011', startDate:'07/01/2010', endDate:'06/30/2011', statusInd:'A').save(failOnError:true)
        new Aidy(code:'1112', desc:'July 2011 - June 2012', startDate:'07/01/2011', endDate:'06/30/2012', statusInd:'A').save(flush:true,failOnError:true)
        println "Loaded " + Aidy.count() + " Aid Years"
    }
    def destroy = {
    }
}
4

0 に答える 0