• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate & primary keys

 
Cornelius Reckinger
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy, we are designing a new Spring based rewrite of an existing system and we wanted to use Hibernate to abstract out the persistence layer. One of the architects has stated that we cannot use Hibernate because it cannot handle tables that have been defined without primary keys and that iBatis is the best solution. Can anyone here validate that position?
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is inaccurate as you can define your id as a composite of fields. You can map a legacy database to Hibernate.

Mark
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Indeed, this shouldn't be a problem.

You can even map Hibernate based component to database views.

As far as doing compound keys, it's easy. Here's a simple table with two fields acting as keys together:



That scenario can be mapped as simply as using the following class:



You can find the whole example here: Hibernate and Compound Primary Keys

-Cameron McKenzie
[ July 24, 2008: Message edited by: Cameron Wallace McKenzie ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic