A short answer to my question: why are you doing this, is a functional test, and it can be removed from JVM applications.
, , , -. , , Remote-Control Grails (https://github.com/alkemist/grails-remote-control), . ,
assert remote {
MyDomainOb.findByName('fred') != null
}
, , , . .
, - , , - , . , hibernate , JVM? : -
Session currentSession
def setup() {
ApplicationContext context = (ApplicationContext) ServletContextHolder.getServletContext().getAttribute(GrailsApplicationAttributes.APPLICATION_CONTEXT);
SessionFactory sf = context.getBean('sessionFactory')
currentSession = sf.getCurrentSession()
}
GebSpec, currentSession.clear() currentSession.flush()
, currentsession.clear() .
. , , remote.