Combination of GetNamedQuery, SetResultTransformer and Future does not work?

61 views
Skip to first unread message

dsergiu77

unread,
Feb 10, 2012, 5:21:31 AM2/10/12
to nhusers
Hi,

I need to get an overview of the tasks still open for a given
employee.
For this I call a named query which contains an SQL statement and
transform the results in a dto object:

It works fine If I get the results of the query directly:
var empOverviewList = Session.GetNamedQuery("THOForEmployee")
.SetInt32("EmployeeId", employeeId)
.SetResultTransformer(Transformers.AliasToBean<TaskHeaderOverview>())
.List<TaskHeaderOverview>();

But if I try to delay the query call using Future<>() and iterate over
the result, then the dto's fields all contain empty values. It looks
like the values were not assigned or were asigned too early, before
the query was run.

var empOverviewList = Session.GetNamedQuery("THOForEmployee")
.SetInt32("EmployeeId", employeeId)
.SetResultTransformer(Transformers.AliasToBean<TaskHeaderOverview>())
.Future<TaskHeaderOverview>();
foreach(TaskHeaderOverview item in empOverviewList)
{
// item has all fields "empty"
}

Do you know of any issue with this combination?

Thanks and regards,
Sergiu Dauceanu.
Reply all
Reply to author
Forward
0 new messages