In grails, I have a Domain class and can be requested in BootStap.groovy
def xref = AppXref.find{user_nm == 'john'}
However, as soon as I moved the code to a method of another domain class, I will have the following error.
Servlet.service() for servlet [default] in context with path [/myapp] threw exception
Message: Could not obtain current Hibernate Session; nested exception is org.hibernate.HibernateException: No Session found for current thread
Here is my hibernation configuration in Config.groovy
hibernate {
cache.use_second_level_cache = true
cache.use_query_cache = false
cache.region.factory_class = 'org.hibernate.cache.ehcache.EhCacheRegionFactory'
singleSession = true
flush.mode = 'manual'
}
I changed cache.use_query_cache to true. But that didn't matter.
source
share