-->
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.  [ 5 posts ] 
Author Message
 Post subject: How to map to a table which is not having a primary key
PostPosted: Tue Jun 22, 2010 12:38 pm 
Newbie

Joined: Tue Jun 22, 2010 12:30 pm
Posts: 2
How to map to a table which is not having a primary key??

I want to know how we can map it..i searched a lot didnot find any replies....please help me geeks...

...


Top
 Profile  
 
 Post subject: Re: How to map to a table which is not having a primary key
PostPosted: Tue Jun 22, 2010 1:53 pm 
Newbie

Joined: Fri May 21, 2010 8:37 am
Posts: 14
Quote:
How can I map a table (or view) with no primary key?
Every table (or even view) should have some unique key. The mathematical definition of a relation is a set of tuples. (Sets do not permit duplicate elements.) Furthermore, truly identical rows can not possibly have any meaningful semantics from the user's perspective.

In some cases it may be sensible to go as far as mapping all columns of a view as a <composite-id/>, but there is almost always some smaller business key. (Note that Hibernate does not require that this unique key be enforced by the database schema, of course.)


Top
 Profile  
 
 Post subject: Re: How to map to a table which is not having a primary key
PostPosted: Wed Jun 23, 2010 8:32 am 
Newbie

Joined: Tue Jun 22, 2010 12:30 pm
Posts: 2
[
am agreeing wat you had said with ..am having table which does not have a pk. will i be able to use hibernate for mapping to that table what should be the value i have to give for ID element in mapping file ......is it possible ..pls answer .........

Thanks in Advance
Vijin


Top
 Profile  
 
 Post subject: Re: How to map to a table which is not having a primary key
PostPosted: Wed Jun 23, 2010 11:06 am 
Regular
Regular

Joined: Mon Aug 07, 2006 6:22 pm
Posts: 67
The table may not define a primary key, but you're going to have to determine the set of columns in the table that represent a "composite unique value" for each row of the table. If there is a single column value that will always be unique in the table, then you could use that. If not a single column, then some combination of multiple columns should represent that unique key. Read the sections of the documentation that talk about defining a composite id.


Top
 Profile  
 
 Post subject: Re: How to map to a table which is not having a primary key
PostPosted: Wed Jun 23, 2010 11:36 am 
Beginner
Beginner

Joined: Fri Jul 20, 2007 10:38 am
Posts: 49
I think if a table doesn't specifically have a PK, all columns combined are it's pk.


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