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

前端 未结 2 1624
半阙折子戏
半阙折子戏 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条回答
  •  猫巷女王i
    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{}

提交回复
热议问题