3
嘿,我正在建立一個m:m db關係的GRAILS應用程序。當我嘗試顯示條目時,衆所周知的「未能懶惰地初始化角色集合...沒有會話或會話被關閉」錯誤被顯示。未能懶洋洋地初始化一個角色集合
一類是:
class Hazzard{
static hasMany = [warning:Warning]
static constraints = {
text(size:1..5000)
}
String name
String text
String toxicity
}
其他:
class Warning{
static hasMany = [hazzard:Hazzard]
static belongsTo = Hazzard
static constraints = {
text(size:1..5000)
}
String code
String text
}
在哈扎德/顯示下面的代碼工作正常
<g:each in="${hazzardInstance.warning}" var="p">
<li><g:link controller="Warning" action="show" id="${p.id}">${p?.encodeAsHTML()}</g:link></li>
</g:each>
但在其他網頁下面的代碼將提供錯誤:
<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>
任何線索哪裏失敗?
您使用的是哪個版本的Grails? – 2011-01-27 13:26:30
我正在使用GRAILS版本:1.3.6 – BadSkillz 2011-01-28 17:16:15