HibernateException: No Session found for current thread when GORM query moved into another domain class

前端 未结 2 1566
半阙折子戏
半阙折子戏 2020-12-21 00:50

In grails, I have a Domain class and can be queried in BootStap.groovy

def xref = AppXref.find{user_nm == \'john\'}

However, once I moved

相关标签:
2条回答
  • 2020-12-21 01:19

    domain class methods are NOT transactional, so you have to make sure, that they are invoked in a TX-context: either put them in a service, or use .withTransaction{}

    0 讨论(0)
  • 2020-12-21 01:41

    Adding @Transactional on the method worked for me.

    0 讨论(0)
提交回复
热议问题