Hi,
This post is a duplicate of a post at:
http://forums.java.net/jive/thread.jspa?threadID=22135&tstart=15 As I haven't received any answers there, I'm trying my luck here.
Let's say I have to tables: EMPLOYEE(emp_id, name, version) and ADDRESS(adr_id, street, emp_id, version), both have a version field.
I have the following Employee-object, using the secondarytable annotation to get the address fields as well:
@Entity
@SecondaryTable(name="ADDRESS", pkJoinColumns=@PrimaryKeyJoinColumn(name="EMP_ID"))
public class Employee{
@Id
private
String emp_id;
@Column(table="street")
private String street;
private String name;
...
}
QUESTION 1: How do I handle multiple version fields? (one for each table, assuming that the address table might be updated in other ways that through the employee-object)
QUESTION 2: what if the relation was the other way around, with the following database:
EMPLOYEE(emp_id, name, version, adr_id)
ADDRESS(adr_id, street, version)
Is there a way to solve this, without making the Address table the primary table, and the employee the secondary?
QUESTION 3: what if the relation was set up through a mapping table, giving the following database:
EMPLOYEE(emp_id, name, version)
ADDRESS(adr_id, street, version)
EMP_ADR(emp_adr_id, emp_id, adr_id)