throw new OpenEJBException("Relation role source ejb not found " + ejbName);
}
if (!(enterpriseBeanInfo instanceof EntityBeanInfo)) {
throw new OpenEJBException("Relation role source ejb is not an entity bean " + ejbName);
}
final EntityBeanInfo entityBeanInfo = (EntityBeanInfo) enterpriseBeanInfo;
cmrFieldInfo.roleSource = entityBeanInfo;
// RoleName: this may be null
cmrFieldInfo.roleName = role.getEjbRelationshipRoleName();
cmrFieldInfo.synthetic = role.getCmrField() == null;
// CmrFieldName: is null for uni-directional relationships
if (role.getCmrField() != null) {
cmrFieldInfo.fieldName = role.getCmrField().getCmrFieldName();
// CollectionType: java.util.Collection or java.util.Set
if (role.getCmrField().getCmrFieldType() != null) {
cmrFieldInfo.fieldType = role.getCmrField().getCmrFieldType().toString();
}
if (cmrFieldInfo.fieldType == null && relatedRole.getMultiplicity() == Multiplicity.MANY) {
cmrFieldInfo.fieldType = Collection.class.getName();
}
} else {
final String relatedEjbName = relatedRole.getRelationshipRoleSource().getEjbName();
final EnterpriseBeanInfo relatedEjb = infos.get(relatedEjbName);
if (relatedEjb == null) {
throw new OpenEJBException("Relation role source ejb not found " + relatedEjbName);
}
if (!(relatedEjb instanceof EntityBeanInfo)) {
throw new OpenEJBException("Relation role source ejb is not an entity bean " + relatedEjbName);
}
final EntityBeanInfo relatedEntity = (EntityBeanInfo) relatedEjb;
relatedRole.getRelationshipRoleSource();
cmrFieldInfo.fieldName = relatedEntity.abstractSchemaName + "_" + relatedRole.getCmrField().getCmrFieldName();
if (relatedRole.getMultiplicity() == Multiplicity.MANY) {
cmrFieldInfo.fieldType = Collection.class.getName();