Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem in Mapping

 
Anupam Dee
Ranch Hand
Posts: 42
Firefox Browser Tomcat Server Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a Customer Class and an Address class as follows

Customer.java


Address.java


Now I want to have two customers with the same address
e.g


//Now when i try to retrieve the Customer Object and iterate over the list i am not getting the address for the second customer. I am getting null there.

These are my HBM files

Address.hbm.xml


Customer.hbm.xml



I am new to hibernate mapping.. please help me...

And i am a bit confused about the mapping strategies in hibernate..please suggest a good link too.
 
Bill Gorder
Bartender
Posts: 1682
7
Android IntelliJ IDE Linux Mac OS X Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The way you have your objects defined you are expecting to a customer to have one address and that address to belong to exactly one Customer. But the way you are attempting to use it you are saying that one address can have many customers. With the way you have it defined you must define 2 Addresses with their own unique persistent ids even if they are both "ABCStreet"
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic