Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grails 3 org.hibernate.HibernateException: No Session found for current thread #38

Closed
olliefreeman opened this issue Oct 5, 2015 · 5 comments

Comments

@olliefreeman
Copy link

Don't know if this is a grails 3 issue or the plugin issue, or if I shouldn't be able to do this.

I want to preload data into the database for known datatypes, (reference data).
This post is from 2010 so it is very possible capabilities have changed we shouldn't be able to do this
http://refactr.com/blog/2012/01/grails-database-migration-gotchas/
but I'd like to be able to call save() on a domain class from inside a change set however i'm getting a no session found for current thread.

Is this intended behaviour or should i be able to do this?

@emilio2hd
Copy link

Same here 😞

@emilio2hd
Copy link

@olliefreeman I guess GORM it's not supported anymore, the documentation says:

change {
            // arbitrary code; make changes directly and/or return a
            // SqlStatement using the sqlStatement(SqlStatement sqlStatement)
            // method or multiple with sqlStatements(List sqlStatements)

            confirm 'change confirmation message'
         }

http://grails-plugins.github.io/grails-database-migration/docs/manual/guide/groovyChanges.html

@vitorbertazoli
Copy link

I'm having the same issue with Grails 3.2.0.M1 and database-migrations 2.0.0.RC4
here's a link to an example
https://github.com/vitorbertazoli/GrailsTest

@jameskleeh
Copy link
Contributor

The workaround is to wrap your code with Domain.withNewSession { }

@jameskleeh
Copy link
Contributor

Fixed in the current snapshot by d737ad6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants