ethnarch wrote:
There should be nothing stopping you from just iterating over the list of objects that is returned and then creating any objects out of those results that you want?
Thank you very much for your answer! The problem is that I don't know which type to cast each column to, so I cannot create any new object from the results :(
The query result is composed of many rows. Each of these rows has some columns. How can I know which data type is in each column, programatically?
What I wanted was something like this (pseudo-Java :P) :
Code:
//compose Query q...
List results = q.list();
types = q.getColumnTypes();
for(row in results) do
for(i=0; i<row.columns.length;i++) do
print ( [b](types.get[i])[/b] row[i] ); //note the [b]cast[/b] inside the print()
end
end
ethnarch wrote:
If you prefer you can even use this syntax to create a map out of it.
Code:
select new java.util.HashMap(place.location as location, car.license_plate as licensePlate)
from Place place, Car car
where car.license_plate = 'foo'
This idea is pretty nice! However, how do I know which object type to cast to when I call the map.get(location) ?
Like this:
Code:
(type?) map.get(location)
Thank you!