I have this problem regarding my Jasper Report on Grails wherein I should display the contents of a particular model having this properties
class Schedule {
Subject subject
Room room // another class having only a single property [room:String]
DayOfWeek day //days of the week having only a single property [day:String]
String timeStart
String timeEnd
//constraints
}
class Subject {
Course course
String section
static hasMany = [schedule: Schedule]
// constraints
}
The problem is that when I try to call the action from the controller where the jasperReport
will be getting the Schedule.list()
, I get this error in return
URI /Portal/jasper/index
Class org.hibernate.LazyInitializationException
Message could not initialize proxy - no Session
Here's the controller and view code.
// ScheduleController
def report() {
List scheduleList = Schedule.list()
chain(controller:'jasper', action:'index', params:params,
model:[data:scheduleList])
}
//view
<g:jasperReport jasper="schedule_list"
controller="schedule"
action="report"
format="pdf, html"
name="Schedule List"
description=" " />
In attempt to resolve this problem, I tried to parse the properties in the domain using this theory below. But in return the report returns all fields on the report null
having the correct number of records.
List scheduleList = Schedule.list().collect {
[cell:
[it.subject.toString(),
it.room.toString(),
it.day.toString(),
it.timeStart,
it.timeEnd
],id: it.id
]
} as List
Here's the fields name located in the jasper report [.jrxml]
<field name="subject" class="java.lang.String"/>
<field name="room" class="java.lang.String"/>
<field name="day" class="java.lang.String"/>
<field name="timeStart" class="java.lang.String"/>
<field name="timeEnd" class="java.lang.String"/>
How can I resolve this problem?