-->
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.  [ 4 posts ] 
Author Message
 Post subject: How to map to a database view that has no Primary Key
PostPosted: Mon Aug 29, 2005 10:55 am 
Newbie

Joined: Mon Aug 29, 2005 10:49 am
Posts: 2
Hi,

I have an existing database view that has no primary key. Since <Id> is a manadatory element for <class> in the mapping file, I am not sure of how to map this view. I know that as far as Hibernate is concerned view is mapped in the same way that a table is.

Is there a way to map a view that has no primary key?

Thanks a lot,
Jade.


Top
 Profile  
 
 Post subject: RE: How to map to a database view that has no Primary Key
PostPosted: Mon Aug 29, 2005 1:12 pm 
Newbie

Joined: Mon Aug 29, 2005 1:04 pm
Posts: 9
Location: Hyderabad, INDIA
Jade,

Yes <id> is a mandatory element, still you can assign id to a non-primary key column and mention the generator class as assigned.

HTH,
Raza Naqvi


Top
 Profile  
 
 Post subject: RE: How to map to a database view that has no Primary Key
PostPosted: Mon Aug 29, 2005 1:17 pm 
Newbie

Joined: Mon Aug 29, 2005 1:04 pm
Posts: 9
Location: Hyderabad, INDIA
Sample code

<id name="id" column="any column" type="java.lang.Integer">
<generator class="assigned" />
</id>

Handle duplicate entry exceptions.

HTH,
Raza Naqvi


Top
 Profile  
 
 Post subject: How to map to a database view that has no Primary Key
PostPosted: Mon Aug 29, 2005 2:12 pm 
Newbie

Joined: Mon Aug 29, 2005 10:49 am
Posts: 2
Hi Thanks for your reply. I am aware that, any column with unique values can be mapped as Id.

But the existing legacy view doesn't have an unique values including compisite id.

So my question is how do we handle when View doesn't have any unique columns including compisite columns?

Thanks,
Jade.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.