• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Hibernate & primary keys

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author and cow tipper
Posts: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic