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
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...
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.