-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Mapping a view with no unique key
PostPosted: Tue Dec 18, 2007 6:46 pm 
Newbie

Joined: Fri Apr 30, 2004 12:32 pm
Posts: 3
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


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 18, 2007 9:41 pm 
Regular
Regular

Joined: Sat Nov 25, 2006 11:37 am
Posts: 72
If your view is NOT returning duplicate rows you can map it with a composite key containing all the columns returned.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.