* INTERNAL:
* Process a one to one setting into an EclipseLink OneToOneMapping.
*/
public void process() {
// Initialize our mapping now with what we found.
OneToOneMapping mapping = initOneToOneMapping();
if (m_mappedBy == null || m_mappedBy.equals("")) {
// Owning side, look for JoinColumns or PrimaryKeyJoinColumns.
processOwningMappingKeys(mapping);
} else {
// Non-owning side, process the foreign keys from the owner.
OneToOneMapping ownerMapping = null;
if (getOwningMapping(m_mappedBy).isOneToOneMapping()){
ownerMapping = (OneToOneMapping)getOwningMapping(m_mappedBy);
} else {
// If improper mapping encountered, throw an exception.
throw ValidationException.invalidMapping(getJavaClass(), getReferenceClass());
}
Map<DatabaseField, DatabaseField> targetToSourceKeyFields;
Map<DatabaseField, DatabaseField> sourceToTargetKeyFields;
// If we are within a table per class strategy we have to update
// the primary key field to point to our own database table.
if (getDescriptor().usesTablePerClassInheritanceStrategy()) {
targetToSourceKeyFields = new HashMap<DatabaseField, DatabaseField>();
sourceToTargetKeyFields = new HashMap<DatabaseField, DatabaseField>();
for (DatabaseField fkField : ownerMapping.getSourceToTargetKeyFields().keySet()) {
// We need to update the pk field to be to our table.
DatabaseField pkField = (DatabaseField) ownerMapping.getSourceToTargetKeyFields().get(fkField).clone();
pkField.setTable(getDescriptor().getPrimaryTable());
sourceToTargetKeyFields.put(fkField, pkField);
targetToSourceKeyFields.put(pkField, fkField);
}
} else {
targetToSourceKeyFields = ownerMapping.getTargetToSourceKeyFields();
sourceToTargetKeyFields = ownerMapping.getSourceToTargetKeyFields();
}
mapping.setSourceToTargetKeyFields(targetToSourceKeyFields);
mapping.setTargetToSourceKeyFields(sourceToTargetKeyFields);
}