wood burning stoves*
The moose likes Object Relational Mapping and the fly likes [Hibernate] How do you map value objects? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "[Hibernate] How do you map value objects?" Watch "[Hibernate] How do you map value objects?" New topic

[Hibernate] How do you map value objects?

Joshua White
Ranch Hand

Joined: Jun 04, 2001
Posts: 97
I have a customer object and a customer table. The customer table contains address information. I have chosen to seperate this information in the customer object into a value object named address. How would I map the address value object? I have included a example mapping of the customer object below.



[ June 22, 2004: Message edited by: Joshua White ]
Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

You can split table mappings up into separate POJOs. In fact this is what Hibernate recommend you do (unless address is not a nullable property - in which case its clearer if you keep them together). Write a mapping for each part of the table - customer & address - give them the same PK column, but different POJO names. Then just treat the as you would normal objects.

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
It is sorta covered in the JavaRanch Style Guide.
subject: [Hibernate] How do you map value objects?