Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
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 Android Security Essentials Live Lessons this week in the Android 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
Author

[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.

Regards,

Joshua



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

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
 
wood burning stoves
 
subject: [Hibernate] How do you map value objects?
 
Similar Threads
ORA-00001: unique constraint exception
Simple mapping issue for Hibernate newbie
One-to-One mapping problem
Hibernate Issue
Hibernate inserting man-to-one fails