Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ CAY-2401 Modeler: NPE in ObjEntity sync action
CAY-2405 Broken prefetch of entity with inheritance and attribute with custom java type
CAY-2411 Wrong resolution of ExtendedType with ValueObjectType for inherited class
CAY-2420 Modeler: search is not performed for Stored Procedures
CAY-2427 Modeler: Undo throws exeption
CAY-2429 Generate classes: Invalid template type: EMBEDDABLE_SINGLE_CLASS

----------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.apache.cayenne.configuration.DataChannelDescriptor;
import org.apache.cayenne.dbsync.merge.context.EntityMergeSupport;
import org.apache.cayenne.dbsync.naming.DefaultObjectNameGenerator;
import org.apache.cayenne.map.DbAttribute;
import org.apache.cayenne.map.DbEntity;
import org.apache.cayenne.map.DbRelationship;
import org.apache.cayenne.map.ObjEntity;
Expand Down Expand Up @@ -99,28 +100,34 @@ protected void syncDbEntity() {
// filter out inherited entities, as we need to add attributes only to the roots
filterInheritedEntities(entities);

boolean hasChanges = false;
for(ObjEntity entity : entities) {

DbEntitySyncUndoableEdit.EntitySyncUndoableListener listener = undoableEdit.new EntitySyncUndoableListener(
entity);

merger.addEntityMergeListener(listener);

Collection<DbAttribute> meaningfulFKs = merger.getMeaningfulFKs(entity);

// TODO: addition or removal of model objects should be reflected in listener callbacks...
// we should not be trying to introspect the merger
if (merger.isRemovingMeaningfulFKs()) {
undoableEdit.addEdit(undoableEdit.new MeaningfulFKsUndoableEdit(entity, merger
.getMeaningfulFKs(entity)));
if (merger.isRemovingMeaningfulFKs() && !meaningfulFKs.isEmpty()) {
undoableEdit.addEdit(undoableEdit.new MeaningfulFKsUndoableEdit(entity, meaningfulFKs));
hasChanges = true;
}

if (merger.synchronizeWithDbEntity(entity)) {
mediator.fireObjEntityEvent(new EntityEvent(this, entity, MapEvent.CHANGE));
hasChanges = true;
}

merger.removeEntityMergeListener(listener);
}

application.getUndoManager().addEdit(undoableEdit);
if(hasChanges) {
application.getUndoManager().addEdit(undoableEdit);
}
}
}

Expand Down