URGENT: OneToOne mapping NOT on PK or FK

View: New views
2 Messages — Rating Filter:   Alert me  

URGENT: OneToOne mapping NOT on PK or FK

by bmelloni :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Sorry about the Urgent, I am supposed to finish this today.

1) I am mapping 2 tables (employee and person) that I cannot change.  Both tables contain an employeeId and have a 1-1 relationship based on it, but the employeeId column is NOT the PK in either table.  The @OneToOne mapping seems to require something like employee.personID to map to the PK of person.

How can I map the relationship based on employeeId column?  

2) Again, in the employee table, I have a supervisorId column (this one does contain the PK).

How do I map the relationship from employee to employee based on the supervisorId?

Re: URGENT: OneToOne mapping NOT on PK or FK

by James Sutherland :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Perhaps include the schema and your object model.

If the employeeId is not the Id of the Entity, then how this can be mapped may depend on your JPA provider.
For the supervisorId, this should just be a normal OneToOne mapping.

See,
http://en.wikibooks.org/wiki/Java_Persistence/OneToOne

http://en.wikibooks.org/wiki/Java_Persistence/Relationships#Filtering.2C_Complex_Joins