• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Table Design Question

 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • 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?
 
Mark Spritzler
ranger
Sheriff
Posts: 17276
6
IntelliJ IDE Mac Spring
  • 0
  • Mark post as helpful
  • send pies
  • 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
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic