• 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

Table Design Question

 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This may not be an ORM specific question but since I am asking in the context of "Java Persistance with Hibernate" I think this forum is as good as any...

In "JP w/H" the authors talk about compositions and they give an example of a USER table with colums for ADDRESS in the USER table. And then using a composition mapping to map the ADDRESS data to a seperate Address class that is a property of the User class. Address is a value type and User is an entity. (JP w/H p. 184,185).

While I understand the concept, other than legacy databases, I don't think I would ever impement the association as such. I would want a seperate table with it's own identity for Address and use a ManyToOne type of association. Am I naive to assume this is preferred?
 
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
Yes, you are correct in that in the real world of today you would design Address as having its own table, and that for that example Legacy databases might have address info in the User table.

And it is being used just as an example to should how to map/annotate a Composition.

Later on you will probably see a better example with a MonetaryAmount object.

So just look at it that way and say oh I see @Embeddable and @Embedded or <component....>

I say this everytime when teaching the Hibernate classes.

Mark
[ January 28, 2007: Message edited by: Mark Spritzler ]
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Mark. I assumed as much. I just wanted to make sure I wasn't missing something. I'm sure as I continue through the book I'll have some more of these types of question.
 
reply
    Bookmark Topic Watch Topic
  • New Topic