File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate and Primary Key

 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi ,

I am trying to use the Hibernate Plugin to generate the hbm files for the Application .

But this complains that my Table doesn't have a Primary key .

so i have a question here

Will the Hibernate will not work if the Tables don't have a Primary Key concept ?

Thanks in advance.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. But then a relational data model that doesn't define primary keys is arguably broken.

As has been discussed at length in this forum (have a search through the older posts) an entity in a relational database without a primary key cannot be relational so will not work with an Object-Relational Mapping tool. There are partial workarounds (again, a brief search will get you these) but the easiest fix is to correct your data model. Is there a reason you defined an entity without a primary key?
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need a primary key.

-Cameron McKenzie
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot Paul and Cameron
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic