This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes hibernate mapping xml issue. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "hibernate mapping xml issue." Watch "hibernate mapping xml issue." New topic
Author

hibernate mapping xml issue.

mano ranjan
Ranch Hand

Joined: Jul 12, 2007
Posts: 102
Hi,
I have table which does not have a primary key .The hbm xml is showing error without primary key.so is there any other way to map the xml without primary key ..

thanks
mano.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Hibernate is an object-relational mapping tool. Data without a primary key is not relational. The problem is that without an id to uniquely identify a row there is no way this data can partake in a relationship. So Hibernate cannot support it.

What you should do is add a surrogate key to your table. If you can't do this, you can map the entire table as a composite key, though this will only work if your table doesn't include duplicate data. If neither of these are possible, don't map the table and handle it in bespoke manner via JDBC (which shouldn't be too disruptive if your persistance code uses a pattern like DAO).


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
 
wood burning stoves
 
subject: hibernate mapping xml issue.
 
Similar Threads
Hibernate Query by Example
insert or update???
Hibernate Mapping problem because no primary key in database
entity bean for a table with No Primary key : Please Help,,,, URGENT
confused about primary key