【问题标题】:HibernateException: No session currently bound to execution contextHibernateException:当前没有会话绑定到执行上下文
【发布时间】:2010-03-08 22:30:58
【问题描述】:

我正在尝试使用 Grails 和 Postgres 创建一个非常基本的 REST 式 Web 服务。我有 read() 和 delete() 方法工作,但我无法让 create() 工作。 Hibernate 只是抱怨,“HibernateException:当前没有会话绑定到执行上下文。”这是我的创建方法:

def create = {
  def member = new Member(params)
  member.save()
  render(status: 201)
}

任何建议都会很棒。谢谢。

【问题讨论】:

    标签: hibernate grails groovy


    【解决方案1】:

    问题解决了!

    因为我有 EJB3 注释文件作为我的 Grails 域类,所以我必须为映射创建自己的 hibernate.cfg.xml。我尝试从

    <property name="current_session_context_class">org.hibernate.context.ManagedSessionContext</property>
    

    <property name="current_session_context_class">thread</property>
    

    它们都产生了 Hibernate 会话错误。然后我终于找到了 this discussion,这表明你的 Hibernate 配置文件中根本不应该有这个属性。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-12-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-09
      • 2023-03-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多