This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
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
Register / Login


JavaRanch » Java Forums » Databases » Object Relational Mapping
Reply 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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: [Hibernate] How do you map value objects?
 
Similar Threads
ORA-00001: unique constraint exception
One-to-One mapping problem
Hibernate inserting man-to-one fails
Simple mapping issue for Hibernate newbie
Hibernate Issue