-->
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: Fetching data from a Database Vew with no primary key
PostPosted: Fri Nov 05, 2004 12:46 am 
Newbie

Joined: Thu Nov 04, 2004 9:41 am
Posts: 1
I have a Database View based on multiple tables . I can't have a primary key for a view(since it is virtual). I map through composite key. When I try to fetch data from the Database View using 'distinct' clause, I get only first record of every group but repeated n times(i.e total no of rows of that group)
1.view contains the following records (e.g)

AREA CITY ZIPCODE
-----------------------------------
A CHENNAI 600001
X BANGALORE 500002
B CHENNAI 600004
B MUMBAI 400003
Z MUMBAI 400002
C CHENNAI 600002

Help me out in fetching data from the above view which has no primay key. (Take care that all the column values can be repeated)
My HQL will be: select distinct ... from ...

Also provide me a generalized solution to map any Database View which has no primary key
Also provide me the mapping file(.hbm)


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 06, 2004 7:08 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Quote:
(Take care that all the column values can be repeated)

So this is not really an composite PK. You can't associate them to the session.
What you can do is
Code:
select new MyObject(view1.name, ...) from View view1

_________________
Emmanuel


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.