Skip to content

Hibernate exceptions in Grails 2.5.0 #16

Description

@paulbarker

It looks like the Localization.decodeMessage() method is causing this error when it tries to call Localisation.findAll():

HibernateException: No Session found for current thread

I found one solution was to wrap the findAll() call in a withNewSession closure like this:

Localization.withNewSession {
    def lst = Localization.findAll(
        "from org.grails.plugins.localization.Localization as x where x.code = ? and x.locale in ('*', ?, ?) order by x.relevance desc",
        [code, locale.getLanguage(), locale.getLanguage() + locale.getCountry()])
    msg = lst.size() > 0 ? lst[0].text : missingValue
}

There may be other areas where this is needed or there may be other, more appropriate solutions - I can't call myself a Grails or even a Java expert so I thought I'd just let you know and maybe you'll be able to update the plugin (which is really, really useful, by the way!)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions