'Grails upgrade from 2 to 4 ,unable to fetch data from DB
i am upgrading my grails 2 app to grails 4. versions are
Hibernate 5 , Grails 4.0.10 , JVM 8
my problem is i am unable to fetch data from db by using User.findByName(....) or any other findBy or get() . it always says org.springframework.dao.DataAccessResourceFailureException: Could not obtain current Hibernate Session; nested exception is org.hibernate.HibernateException: No Session found for current thread at org.grails.orm.hibernate.GrailsHibernateTemplate.getSession(GrailsHibernateTemplate.java:335)
my hibernate config has
> hibernate :
> cache:
> use_second_level_cache : true
> use_query_cache : true
> provider_class : "net.sf.ehcache.hibernate.EhCacheProvider"
> region:
> factory_class : 'org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory'
> format_sql : false
> generate_statistics : false
>
> allow_update_outside_transaction: true
if I use @Transactional to the method ,then i'm able to fetch the data otherwise it fails.
is there any other way to fetch the data like in previous versions?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
