Hi everyone, I am creating a GRAILS application with m: m db ratio. When I try to show the records, the well-known "failed to lazily initialize the role collection ... session or session was not closed", an error is displayed.
One class:
class Hazzard{
static hasMany = [warning:Warning]
static constraints = {
text(size:1..5000)
}
String name
String text
String toxicity
}
other:
class Warning{
static hasMany = [hazzard:Hazzard]
static belongsTo = Hazzard
static constraints = {
text(size:1..5000)
}
String code
String text
}
Hazzard / shows that the following code works fine
<g:each in="${hazzardInstance.warning}" var="p">
<li><g:link controller="Warning" action="show" id="${p.id}">${p?.encodeAsHTML()}</g:link></li>
</g:each>
but the following code is shown on other pages:
<g:set var="haz" value="${Hazzard.get(params.id)}" />
<h1>${haz.name}</h1>
<p>${haz.text}</p>
<h1>Toxiciteit</h1>
<p>${haz.toxicity}</p>
<br/>
<h1>Gevaren(H) en voorzorgen(P)</h1>
<g:each in="${haz.warning}" var="p"> --> This is where the error pops-up
${p.text}
</g:each>
Any tips on where this fails?
source
share