wood burning stoves 2.0*
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

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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
Consider Paul's rocket mass heater.
subject: [Hibernate] How do you map value objects?
Similar Threads
Simple mapping issue for Hibernate newbie
One-to-One mapping problem
Hibernate Issue
ORA-00001: unique constraint exception
Hibernate inserting man-to-one fails