Hi,
I'm having trouble getting something to work. Here is an example of what I'm trying to do. I have a Company class. It had an shipTo Address and a billTo Address, both of whch are Address objects. I've got both of these variables annoted like:
Code:
@OneToOne
@PrimaryKeyJoinColumn
private Address billingAddress;
@OneToOne
@PrimaryKeyJoinColumn
private Address shippingAddress;
When I attempt to create a Company with both addresses, the first Address object I created and saved is saved for both variables. However both Addresses appear in the Address table. Here is the code I'm using for this:
Code:
ContactInfo co = new Company();
ci.setEmailAddress("me@me.com");
ci.setFax(22);
ci.setPhone1(33);
ci.setPhone2(44);
ci.setUrl("www.crap.com");
Address sa = new Address(
"24 Madison Ave.", null, "Badland",
"ME", 04105);
Address ba = new Address(
"25 Liberty Ave.", null, "Frank",
"ME", 04444);
ci.setShippingAddress(sa);
ci.setBillingAddress(ba);
session.save(sa);
session.save(ba);
session.save(ci);
Any help is greatly appreciated. I just haven't been able to find the answer. I'm trying to learn Hibernate.
Thanks,
Mark