if (roles.size() != 2) {
continue;
}
// get left entity
EjbRelationshipRole leftRole = roles.get(0);
RelationshipRoleSource leftRoleSource = leftRole.getRelationshipRoleSource();
String leftEjbName = leftRoleSource == null ? null : leftRoleSource.getEjbName();
Entity leftEntity = entitiesByName.get(leftEjbName);
// get right entity
EjbRelationshipRole rightRole = roles.get(1);
RelationshipRoleSource rightRoleSource = rightRole.getRelationshipRoleSource();
String rightEjbName = rightRoleSource == null ? null : rightRoleSource.getEjbName();
Entity rightEntity = entitiesByName.get(rightEjbName);
// neither left or right have a mapping which is fine
if (leftEntity == null && rightEntity == null) {
continue;
}
// left not found?
if (leftEntity == null) {
throw new OpenEJBException("Role source " + leftEjbName + " defined in relationship role " +
relation.getEjbRelationName() + "::" + leftRole.getEjbRelationshipRoleName() + " not found");
}
// right not found?
if (rightEntity == null) {
throw new OpenEJBException("Role source " + rightEjbName + " defined in relationship role " +
relation.getEjbRelationName() + "::" + rightRole.getEjbRelationshipRoleName() + " not found");
}
String leftFieldName = null;
boolean leftSynthetic = false;
if (leftRole.getCmrField() != null) {
leftFieldName = leftRole.getCmrField().getCmrFieldName();
} else {
leftFieldName = rightEntity.getName() + "_" + rightRole.getCmrField().getCmrFieldName();
leftSynthetic = true;
}
boolean leftIsOne = leftRole.getMultiplicity() == Multiplicity.ONE;
String rightFieldName = null;
boolean rightSynthetic = false;
if (rightRole.getCmrField() != null) {
rightFieldName = rightRole.getCmrField().getCmrFieldName();
} else {
rightFieldName = leftEntity.getName() + "_" + leftRole.getCmrField().getCmrFieldName();
rightSynthetic = true;
}
boolean rightIsOne = rightRole.getMultiplicity() == Multiplicity.ONE;
if (leftIsOne && rightIsOne) {
//
// one-to-one
//