views:

99

answers:

1

I'm trying to create a very basic REST-ish web service with Grails and Postgres. I have the read() & delete() methods working, but I can't get create() to work. Hibernate just gripes, "HibernateException: No session currently bound to execution context." Here's my create method:

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

Any advice would be great. Thanks.

A: 

Problem solved!

Since I have EJB3 annotation files as my Grails domain classes, I had to create my own hibernate.cfg.xml for the mappings. I tried changing from

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

to

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

They both produced Hibernate session errors. Then I finally found http://jira.codehaus.org/browse/GRAILS-3974 which suggests you shouldn't have this property in your Hibernate config file at all.