entity1ToManyRelationship.setPropagatesPrimaryKey(Boolean.TRUE);
entity1ToManyRelationship.setDeleteRule(EODeleteRule.CASCADE);
addRelationship(entity1ToManyRelationship);
if (_flatten) {
EORelationship entity1ToManyFlattenedRelationship = new EORelationship(_relationshipName, new KeyPath(new String[] { entity1ToManyRelationship.getName(), entity2Relationship.getName() }).toKeyPath());
entity1ToManyFlattenedRelationship.setClassProperty(Boolean.TRUE);
addRelationship(entity1ToManyFlattenedRelationship);
}
}
if (createInverseRelationship) {
String entity2ToManyName;
if (_flatten) {
entity2ToManyName = StringUtils.toPlural(StringUtils.toLowercaseFirstLetter(manyToManyEntity.getName()));
} else {
entity2ToManyName = _inverseRelationshipName;
}
EORelationship entity2ToManyRelationship = entity2Relationship.createInverseRelationshipNamed(entity2ToManyName, true);
entity2ToManyRelationship.setClassProperty(Boolean.valueOf(!_flatten));
entity2ToManyRelationship.setPropagatesPrimaryKey(Boolean.TRUE);
entity2ToManyRelationship.setDeleteRule(EODeleteRule.CASCADE);
_entity2.addRelationship(entity2ToManyRelationship);
if (_flatten) {
EORelationship entity2ToManyFlattenedRelationship = new EORelationship(_inverseRelationshipName, new KeyPath(new String[] { entity2ToManyRelationship.getName(), entity1Relationship.getName() }).toKeyPath());
entity2ToManyFlattenedRelationship.setClassProperty(Boolean.TRUE);
_entity2.addRelationship(entity2ToManyFlattenedRelationship);
}
}