You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by "R V V S S V Raju (JIRA)" <ji...@apache.org> on 2011/05/19 13:26:47 UTC
[jira] [Commented] (CAY-1163) Moving DBObject to a different
DataMap causes reverse relationships to be lost
[ https://issues.apache.org/jira/browse/CAY-1163?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13036114#comment-13036114 ]
R V V S S V Raju commented on CAY-1163:
---------------------------------------
//DataMap->removeDbEntity
public void removeDbEntity(String dbEntityName, boolean clearDependencies) {
//DbEntity dbEntityToDelete = dbEntityMap.remove(dbEntityName);
DbEntity dbEntityToDelete = dbEntityMap.get(dbEntityName);
if (dbEntityToDelete != null && clearDependencies) {
for (DbEntity dbEnt : this.getDbEntities()) {
// take a copy since we're going to modify the entity
for (Relationship rel : new ArrayList<Relationship>(
dbEnt.getRelationships())) {
if (dbEntityName.equals(rel.getTargetEntityName())) {
dbEnt.removeRelationship(rel.getName());
}
}
for (Relationship rel : new ArrayList<Relationship>(
dbEntityToDelete.getRelationships())) {
dbEntityToDelete.removeRelationship(rel.getName());
}
}
// Remove all obj relationships referencing removed DbRelationships.
for (ObjEntity objEnt : this.getObjEntities()) {
if (dbEntityToDelete.getName().equals(objEnt.getDbEntityName())) {
for (Relationship rel : new ArrayList<Relationship>(
objEnt.getRelationships())) {
objEnt.removeRelationship(rel.getName());
}
objEnt.clearDbMapping();
}
else {
for (Relationship rel : objEnt.getRelationships()) {
for (DbRelationship dbRel : ((ObjRelationship) rel)
.getDbRelationships()) {
if (dbRel.getTargetEntity().equals(dbEntityToDelete)) {
//((ObjRelationship) rel).clearDbRelationships();
objEnt.removeRelationship(dbRel.getName());
break;
}
}
}
}
}
}
dbEntityMap.remove(dbEntityName);
}
//DataMap->removeObjEntity()
public void removeObjEntity(String objEntityName, boolean clearDependencies) {
ObjEntity entity = objEntityMap.remove(objEntityName);
if (entity != null && clearDependencies) {
// remove relationships that point to this entity
for (ObjEntity ent : getObjEntities()) {
// take a copy since we're going to modify the entity
for (Relationship relationship : new ArrayList<Relationship>(
ent.getRelationships())) {
if (objEntityName.equals(relationship.getTargetEntityName())) {
ent.removeRelationship(relationship.getName());
}
}
for (Relationship relationship : new ArrayList<Relationship>(
entity.getRelationships())) {
entity.removeRelationship(relationship.getName());
}
}
}
}
> Moving DBObject to a different DataMap causes reverse relationships to be lost
> ------------------------------------------------------------------------------
>
> Key: CAY-1163
> URL: https://issues.apache.org/jira/browse/CAY-1163
> Project: Cayenne
> Issue Type: Bug
> Components: Modeler
> Affects Versions: 3.0M5
> Environment: CayenneModeller 3.0M5 under Mac OS X 10.5.6 java version "1.5.0_16"
> Reporter: Stephen Winnall
> Assignee: Andrey Razumovsky
>
> 1) create a new project
> 2) create dataMap OneMap
> 3) create dataMap TwoMap
> 4) in OneMap, create dbEntity Ent1 with attribute One : INTEGER
> 5) in OneMap, create dbEntity Ent2 with attribute Two : INTEGER
> 6) create a relationship and reverse relationship between Ent1.One and Ent2.Two
> 7) move Ent2 into TwoMap using cut and paste
> 8) observe that the relationship for Ent1 has been zapped, though the reverse relationship for Ent2 still exists
> This behaviour leads to missing relationships in the generated schema.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira