I need to map, read-only, a legacy view that does not have a unique id. If I pick an arbitrary column as the id, Hibernate only returns me one row per id value for that column (where many might have that value).
Is there a way to tell Hibernate:
a) Return me all of the rows even if the "id" is not unique; or
b) Have Hibernate generate a unique id "on-the-fly" as I read the rows (I don't really care what the unique id value is); or
c) Allow me to specify SQL for the id (I'm using DB2 which allows me to "select row_number() over() as row_id" as part of my SQL which returns a unique integer id per row along with my data; or
d) Some other way I've not thought about!
Any help would be greatly appreciated.
Thanks,
Nick
|