foreignAttribute = new EOAttribute(); foreignAttribute.setName(targetName+"id"); foreignAttribute.setColumnName(targetName+"id"); selectedEntity.addAttribute(foreignAttribute); foreignAttribute.setPrototype(selectedPK.prototype()); updateClassProperties(selectedEntity,foreignAttribute,false);
foreignAttribute = addAttributeNamed(selectedEntity, targetName+"id", selectedPK.prototype());
        public void addBackRelationship(EOEntity selectedEntity, EOEntity targetEntity, EOAttribute foreignAttribute, boolean isToMany, boolean addBack) {            EORelationship relationship = new EORelationship();            String targetName = targetEntity.name().toLowerCase();            String selectedName = selectedEntity.name().toLowerCase();            EOAttribute selectedPK = (EOAttribute)targetEntity.primaryKeyAttributes().objectAtIndex(0);            log.info(selectedPK + "--" + selectedPK.prototype());            if(foreignAttribute == null) {                foreignAttribute = new EOAttribute();                foreignAttribute.setName(targetName+"id");                foreignAttribute.setColumnName(targetName+"id");                selectedEntity.addAttribute(foreignAttribute);                foreignAttribute.setPrototype(selectedPK.prototype());                updateClassProperties(selectedEntity,foreignAttribute,false);            }            relationship.setName(targetName+(isToMany ? "s" : ""));            selectedEntity.addRelationship(relationship);            EOJoin join = new EOJoin(foreignAttribute,selectedPK);            relationship.addJoin(join);            relationship.setToMany(isToMany);            relationship.setJoinSemantic(EORelationship.InnerJoin);        }