I have a problem trying to create a mapping for the following model:
Person
Address homeAddress
Address workAddress
Address
@Embedded Street street
String city
String country
We need to store the address inlined to the Person Table so our initial thought was to make the Address @Embeddable.
e.g.
@Entity
Person {
@Embedded Address homeAddress
@Embedded Address workAddress
}
The issue is that there will be no distinction between
say a homeAddressCity or a workAddressCity. So again our solution was to have something like this:
@Entity
Person {
@Embedded
@AttributeOverrides({
@AttributeOverride( name="homeAddressCity", column=@Column(name="city") ),
@AttributeOverride( name="homeAddressCountry", column=@Column(name="country") )
})
Address homeAddress
@Embedded
@AttributeOverrides({
@AttributeOverride( name="workAddressCity", column=@Column(name="city") ),
@AttributeOverride( name="workAddressCountry", column=@Column(name="country") )
})
Address workAddress
}
But it doesn't appear like you can modify the mapping for the @Street from the Person Entity. Can you suggest an alternative to this or a solution to our problem?
Thanks very much.
|