• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

hibernate mapping xml issue.

 
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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).
reply
    Bookmark Topic Watch Topic
  • New Topic