groovy « Test « JPA Q&A





1. groovy / grails / unit testing / createCriteria.get    stackoverflow.com

I can mock calls to:

MyDomainClass.createCriteria().list{
    eq('id',id)
    eq('anotherParameter',anotherParameterId)
}
with:
def myCriteria = [
    list : {Closure  cls -> returnThisObject}
]
MyDomainClass.metaClass.static.createCriteria = { myCriteria }
as advised ...

2. Grails doesn't use my data source when running in production or test?    stackoverflow.com

Note that I'm using Grails 2.0.0 Milestone 2. I'm getting the Hibernate error createQuery is not valid without active transaction when I try to WAR/deploy my Grails app or run the app ...