-
1. Re: Query returns Object instead of the right type....
hanyshafik Mar 12, 2009 2:18 AM (in response to dimar1975)The following query
SELECT taskId, taskName FROM TaskList AS a
doesn't return list of tasks instead it will return list of objects, each item in the list describes one row as another list of objects. Each item in the latter list describes one column (e.g. taskName as String).
if you want it to return list of tasks that has only taskid and taskname populated you can you use the following query
SELECT new TaskList(taskId, taskName) FROM TaskList AS a
ofcourse you will need the above constructor for TaskList -
2. Re: Query returns Object instead of the right type....
dimar1975 Mar 12, 2009 5:06 AM (in response to dimar1975)hello!
thank you very much for your advice.
Unfortunately I cannot follow your approach because the number of fields are built at runtime - in other words the user creates at runtime a View of the table.
I should add all possible constructors (they're about 20 fields :-( )
maybe I should create a Native Query..if I don't have other options...
thanks anyway
marco -
3. Re: Query returns Object instead of the right type....
jaikiran Mar 12, 2009 7:49 AM (in response to dimar1975)"dimar1975" wrote:
The problem is that now the list contains Objects and not TaskList......I need TaskList otherwise I will have ClassCastExceptions in other pieces of the code......
Its going to return an Object array. You will have to change the return type since you no longer are expecting an entire TaskList from the query output.