-->
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: what to do if my database don't have Primary Key
PostPosted: Tue Mar 08, 2005 8:14 am 
Newbie

Joined: Wed Feb 23, 2005 9:00 am
Posts: 8
what to do if my database don't have Primary Key. Can i have a class without a primary key. please help me and how to do it tell me.

Thanks in Advance


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 08, 2005 11:56 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Define what you mean by "don't have Primary Key"


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 08, 2005 1:25 pm 
Beginner
Beginner

Joined: Mon Nov 29, 2004 5:34 pm
Posts: 35
I was in similar situation some time back, I have a old table (Old – since I can’t change the table, since it used by many application and I have to debug all of them, if I can anything in that table.)
It did not have any primary key, and when I used the middlegen tool to get the mapping files, if table doesn’t have primary key, it will generate all of them a composite key.
For loading you can write quires, but you cannot update them, since all of them are keys now and you cannot update the records.
So I have make a good choice from that table and change the mapping class file class.hbx.xml file to make one or 2 as keys (Which I was sure that, they will not be updated).
And then I was able to get, save and update the records.


srigold


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 08, 2005 10:03 pm 
Regular
Regular

Joined: Fri Mar 04, 2005 1:33 pm
Posts: 65
Location: U.K.
If you are in a position to alter that table, you can add a primary key which can be just a sequence. Middlegen/Hibernate assumes every table has a primary key and if not it is not a relational entity.


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.