eoneil wrote:
If you convert Addresses to value types, you can add the startDate to the Address, since it's privately held. I'm hoping that sharing Address objects is not crucial. Then the Address type is good for the current address too. Just link the current address from the appropriate collection's Address object, and update this link as needed.
Hi,
Thanks for the reply. I'm not sure what you mean though by changing Address to value types... I mean, the address itself is an object with value typed properties (Strings), isn't it?
And an address can be shared if two or more persons live or have lived at that address (defined by the start- and endDate in the temporalAddress table).
For the current address of a person, I'd love to refer to a *Current* address from the person:
Class person {
private CurrentAddress address;
...
}
Where the CurrentAddress extends the Address class, but uses a secondary table to include the TemporalAddress. Something like
// Not sure if I have all the annotations syntactically right, but you'll get the idea
@SecondaryTable (name="TemporalAddress")
@Where(clause="temporalAddress.endDate IS NULL and person=?personId?")
Class CurrentAddress extends Address {
private Date startDate;
@Table(name="TemporalAddress")
public Date getStartDate() {
return startDate;
}
}
But to find the temporalAddress belonging to that Address, you have to
apply the where/filter
"TemporalAddress.endDate is null and TemporalAddress.personId = Person.id" and that @Where clause is not supported yet in combination with secondary tables.