You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by aa...@apache.org on 2026/09/12 20:55:33 UTC
(cayenne) branch master updated (9027ae4cd -> 7805a829e)
This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/cayenne.git
from 9027ae4cd No more GraphManager. ObjectContext to expose ObjectStore
new 56f946d89 No more GraphManager. ObjectContext to expose ObjectStore
new 7805a829e CAY-3025 ObjectContext to require/return Persistent for all object ops
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
RELEASE-NOTES.txt | 1 +
.../java/org/apache/cayenne/ObjectContext.java | 16 +-
.../org/apache/cayenne/ObjectContextChangeLog.java | 198 -------------
.../main/java/org/apache/cayenne/ObjectStore.java | 15 +-
.../org/apache/cayenne/access/DataContext.java | 61 +---
.../cayenne/access/DataContextDeleteAction.java | 10 +-
.../cayenne/access/DataContextGraphAction.java | 10 +-
.../cayenne/access/DataContextMergeHandler.java | 32 +--
.../cayenne/access/DataContextObjectStore.java | 312 ++++++++-------------
.../access/DefaultObjectMapRetainStrategy.java | 3 +-
.../access/JoinedIdParentAttachmentStrategy.java | 2 +-
.../java/org/apache/cayenne/access/ObjectDiff.java | 28 +-
.../cayenne/access/ObjectMapRetainStrategy.java | 3 +-
.../cayenne/access/ObjectStoreGraphDiff.java | 12 +-
.../cayenne/access/PrefetchProcessorNode.java | 5 +-
.../access/flush/ArcValuesCreationHandler.java | 14 +-
.../flush/DataDomainIndirectDiffBuilder.java | 16 +-
.../cayenne/access/flush/DbRowOpFactory.java | 23 +-
.../access/flush/DefaultDataDomainFlushAction.java | 2 +-
.../access/flush/ValuesCreationHandler.java | 5 +-
.../cayenne/ashwood/AshwoodEntitySorter.java | 2 +-
.../cayenne/commitlog/DeletedDiffProcessor.java | 3 +-
.../org/apache/cayenne/commitlog/DiffFilter.java | 36 +--
.../apache/cayenne/commitlog/DiffProcessor.java | 32 +--
.../configuration/runtime/DataContextFactory.java | 1 +
.../apache/cayenne/graph/ArcCreateOperation.java | 23 +-
.../apache/cayenne/graph/ArcDeleteOperation.java | 23 +-
.../org/apache/cayenne/graph/ChildDiffLoader.java | 44 ++-
.../apache/cayenne/graph/GraphChangeHandler.java | 13 +-
.../apache/cayenne/graph/GraphDiffCompressor.java | 57 ++--
.../apache/cayenne/graph/NodeCreateOperation.java | 13 +-
.../apache/cayenne/graph/NodeDeleteOperation.java | 13 +-
.../java/org/apache/cayenne/graph/NodeDiff.java | 15 +-
.../cayenne/graph/NodeIdChangeOperation.java | 19 +-
.../cayenne/graph/NodePropertyChangeOperation.java | 13 +-
.../cayenne/tx/DataChannelSyncCallbackAction.java | 33 +--
.../apache/cayenne/util/ShallowMergeOperation.java | 4 +-
.../test/java/org/apache/cayenne/CayenneIT.java | 2 +-
.../CayennePersistentObjectInContextIT.java | 6 +-
.../apache/cayenne/ObjectContextChangeLogTest.java | 74 -----
.../apache/cayenne/access/DataContextExtrasIT.java | 12 +-
.../org/apache/cayenne/access/DataContextIT.java | 14 +-
.../cayenne/access/DataContextIdQueryIT.java | 2 +-
.../cayenne/access/DataContextObjectStoreIT.java | 12 +-
.../cayenne/access/DataContextObjectStoreTest.java | 12 +-
.../access/DataContextObjectTrackingIT.java | 8 +-
.../access/DataContextPrefetchMultistepIT.java | 8 +-
.../org/apache/cayenne/access/JointPrefetchIT.java | 8 +-
.../access/NestedDataContextParentEventsIT.java | 2 +-
.../cayenne/access/NestedDataContextReadIT.java | 2 +-
.../cayenne/access/NestedDataContextWriteIT.java | 48 ++--
.../org/apache/cayenne/access/NumericTypesIT.java | 4 +-
.../org/apache/cayenne/graph/NodeDiffTest.java | 19 +-
53 files changed, 478 insertions(+), 867 deletions(-)
delete mode 100644 cayenne/src/main/java/org/apache/cayenne/ObjectContextChangeLog.java
delete mode 100644 cayenne/src/test/java/org/apache/cayenne/ObjectContextChangeLogTest.java
(cayenne) 01/02: No more GraphManager. ObjectContext to expose ObjectStore
Posted by aa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cayenne.git
commit 56f946d895dd92c9ebce00e7b29a4192410f90b1
Author: Andrus Adamchik <an...@objectstyle.com>
AuthorDate: Sat Sep 12 16:02:06 2026 -0400
No more GraphManager. ObjectContext to expose ObjectStore
polishing API, cleanup
---
.../java/org/apache/cayenne/ObjectContext.java | 16 +++++--
.../main/java/org/apache/cayenne/ObjectStore.java | 8 ++--
.../org/apache/cayenne/access/DataContext.java | 49 ++++------------------
.../cayenne/access/DataContextDeleteAction.java | 2 +-
.../cayenne/access/DataContextMergeHandler.java | 4 +-
.../cayenne/access/DataContextObjectStore.java | 16 +++----
.../access/JoinedIdParentAttachmentStrategy.java | 2 +-
.../cayenne/access/ObjectStoreGraphDiff.java | 2 +-
.../cayenne/access/flush/DbRowOpFactory.java | 4 +-
.../cayenne/ashwood/AshwoodEntitySorter.java | 2 +-
.../org/apache/cayenne/graph/ChildDiffLoader.java | 2 +-
.../cayenne/tx/DataChannelSyncCallbackAction.java | 6 +--
.../apache/cayenne/util/ShallowMergeOperation.java | 4 +-
.../test/java/org/apache/cayenne/CayenneIT.java | 2 +-
.../CayennePersistentObjectInContextIT.java | 6 +--
.../apache/cayenne/access/DataContextExtrasIT.java | 12 +++---
.../org/apache/cayenne/access/DataContextIT.java | 14 +++----
.../cayenne/access/DataContextIdQueryIT.java | 2 +-
.../cayenne/access/DataContextObjectStoreIT.java | 12 +++---
.../cayenne/access/DataContextObjectStoreTest.java | 12 +++---
.../access/DataContextObjectTrackingIT.java | 8 ++--
.../access/DataContextPrefetchMultistepIT.java | 8 ++--
.../org/apache/cayenne/access/JointPrefetchIT.java | 8 ++--
.../access/NestedDataContextParentEventsIT.java | 2 +-
.../cayenne/access/NestedDataContextReadIT.java | 2 +-
.../cayenne/access/NestedDataContextWriteIT.java | 48 ++++++++++-----------
.../org/apache/cayenne/access/NumericTypesIT.java | 4 +-
27 files changed, 115 insertions(+), 142 deletions(-)
diff --git a/cayenne/src/main/java/org/apache/cayenne/ObjectContext.java b/cayenne/src/main/java/org/apache/cayenne/ObjectContext.java
index 9b972aa06..147aa68ee 100644
--- a/cayenne/src/main/java/org/apache/cayenne/ObjectContext.java
+++ b/cayenne/src/main/java/org/apache/cayenne/ObjectContext.java
@@ -52,19 +52,25 @@ public interface ObjectContext {
* Returns a collection of objects that are registered with this
* ObjectContext and have a state PersistenceState.NEW
*/
- Collection<Persistent> newObjects();
+ default Collection<Persistent> newObjects() {
+ return getObjectStore().objectsInState(PersistenceState.NEW);
+ }
/**
* Returns a collection of objects that are registered with this
* ObjectContext and have a state PersistenceState.DELETED
*/
- Collection<Persistent> deletedObjects();
+ default Collection<Persistent> deletedObjects() {
+ return getObjectStore().objectsInState(PersistenceState.DELETED);
+ }
/**
* Returns a collection of objects that are registered with this
* ObjectContext and have a state PersistenceState.MODIFIED
*/
- Collection<Persistent> modifiedObjects();
+ default Collection<Persistent> modifiedObjects() {
+ return getObjectStore().objectsInState(PersistenceState.MODIFIED);
+ }
/**
* Returns a collection of MODIFIED, DELETED or NEW objects.
@@ -373,7 +379,9 @@ public interface ObjectContext {
*
* @since 3.0
*/
- boolean hasChanges();
+ default boolean hasChanges() {
+ return getObjectStore().hasChanges();
+ }
/**
* Invalidates a Collection of persistent objects. This operation only
diff --git a/cayenne/src/main/java/org/apache/cayenne/ObjectStore.java b/cayenne/src/main/java/org/apache/cayenne/ObjectStore.java
index 735f8a6f1..9be16c664 100644
--- a/cayenne/src/main/java/org/apache/cayenne/ObjectStore.java
+++ b/cayenne/src/main/java/org/apache/cayenne/ObjectStore.java
@@ -38,23 +38,23 @@ public interface ObjectStore extends GraphChangeHandler {
/**
* Returns a registered object for the id, or null if no such object is registered.
*/
- Persistent getNode(Object nodeId);
+ Persistent getObject(Object nodeId);
/**
* Registers an object under the id.
*/
- void registerNode(Object nodeId, Persistent nodeObject);
+ void registerObject(Object nodeId, Persistent nodeObject);
/**
* Unregisters an object with the id, forgetting any information associated with it. Returns the unregistered
* object, or null if none was registered.
*/
- Persistent unregisterNode(Object nodeId);
+ Persistent unregisterObject(Object nodeId);
/**
* Returns a copy of the collection of all registered objects.
*/
- Collection<Persistent> registeredNodes();
+ Collection<Persistent> registeredObjects();
/**
* Returns registered objects in a given {@link PersistenceState}.
diff --git a/cayenne/src/main/java/org/apache/cayenne/access/DataContext.java b/cayenne/src/main/java/org/apache/cayenne/access/DataContext.java
index 789fe8aba..8c44851c5 100644
--- a/cayenne/src/main/java/org/apache/cayenne/access/DataContext.java
+++ b/cayenne/src/main/java/org/apache/cayenne/access/DataContext.java
@@ -237,32 +237,6 @@ public class DataContext implements ObjectContext {
return objectStore;
}
- /**
- * Returns <code>true</code> if there are any modified, deleted or new
- * objects registered with this DataContext, <code>false</code> otherwise.
- */
- public boolean hasChanges() {
- return objectStore.hasChanges();
- }
-
- /**
- * Returns a list of objects that are registered with this DataContext and
- * have a state PersistenceState.NEW
- */
- @Override
- public Collection<Persistent> newObjects() {
- return objectStore.objectsInState(PersistenceState.NEW);
- }
-
- /**
- * Returns a list of objects that are registered with this DataContext and
- * have a state {@link PersistenceState#DELETED}
- */
- @Override
- public Collection<Persistent> deletedObjects() {
- return objectStore.objectsInState(PersistenceState.DELETED);
- }
-
/**
* @since 3.1
*/
@@ -279,15 +253,6 @@ public class DataContext implements ObjectContext {
}
}
- /**
- * Returns a list of objects that are registered with this DataContext and
- * have a state {@link PersistenceState#MODIFIED}
- */
- @Override
- public Collection<Persistent> modifiedObjects() {
- return objectStore.objectsInState(PersistenceState.MODIFIED);
- }
-
/**
* Returns a collection of all uncommitted registered objects.
*
@@ -363,7 +328,7 @@ public class DataContext implements ObjectContext {
}
for (ObjectId candidateId : inheritanceTree.polymorphicIds(id)) {
- Persistent object = objectStore.getNode(candidateId);
+ Persistent object = objectStore.getObject(candidateId);
if (object != null && object.getPersistenceState() != PersistenceState.HOLLOW) {
return object;
}
@@ -387,7 +352,7 @@ public class DataContext implements ObjectContext {
// first look for the ID in the local ObjectStore
synchronized (objectStore) {
@SuppressWarnings("unchecked")
- T localObject = (T) objectStore.getNode(id);
+ T localObject = (T) objectStore.getObject(id);
if (localObject != null) {
return localObject;
}
@@ -404,7 +369,7 @@ public class DataContext implements ObjectContext {
persistent.setObjectId(id);
persistent.setPersistenceState(PersistenceState.HOLLOW);
- objectStore.registerNode(id, persistent);
+ objectStore.registerObject(id, persistent);
return persistent;
}
@@ -664,7 +629,7 @@ public class DataContext implements ObjectContext {
object.setPersistenceState(PersistenceState.NEW);
synchronized (objectStore) {
- objectStore.registerNode(object.getObjectId(), object);
+ objectStore.registerObject(object.getObjectId(), object);
objectStore.nodeCreated(object.getObjectId());
}
@@ -745,7 +710,7 @@ public class DataContext implements ObjectContext {
@SuppressWarnings("unchecked")
private List<Persistent> resolveRelationshipInSelf(ObjectId sourceId, String relationshipName, boolean resolveToMany) {
- Persistent source = objectStore.getNode(sourceId);
+ Persistent source = objectStore.getObject(sourceId);
if (source == null) {
return null;
}
@@ -1136,7 +1101,7 @@ public class DataContext implements ObjectContext {
// messing up Persistent objects per CAY-845. Originally only parts of "else" were synchronized,
// but we had to expand the lock scope to ensure consistent behavior.
synchronized (objectStore) {
- Persistent cachedObject = objectStore.getNode(id);
+ Persistent cachedObject = objectStore.getObject(id);
// return an existing object
if (cachedObject != null) {
@@ -1159,7 +1124,7 @@ public class DataContext implements ObjectContext {
localObject.setObjectContext(this);
localObject.setObjectId(id);
- objectStore.registerNode(id, localObject);
+ objectStore.registerObject(id, localObject);
localObject.setPersistenceState(PersistenceState.HOLLOW);
return localObject;
diff --git a/cayenne/src/main/java/org/apache/cayenne/access/DataContextDeleteAction.java b/cayenne/src/main/java/org/apache/cayenne/access/DataContextDeleteAction.java
index 30f82f8db..b118d19e7 100644
--- a/cayenne/src/main/java/org/apache/cayenne/access/DataContextDeleteAction.java
+++ b/cayenne/src/main/java/org/apache/cayenne/access/DataContextDeleteAction.java
@@ -95,7 +95,7 @@ class DataContextDeleteAction {
processDeleteRules(object, PersistenceState.NEW);
// if an object was NEW, we must throw it out
- context.getObjectStore().unregisterNode(object.getObjectId());
+ context.getObjectStore().unregisterObject(object.getObjectId());
}
private void deletePersistent(Persistent object) throws DeleteDenyException {
diff --git a/cayenne/src/main/java/org/apache/cayenne/access/DataContextMergeHandler.java b/cayenne/src/main/java/org/apache/cayenne/access/DataContextMergeHandler.java
index 6de6bc3c4..11c6c839b 100644
--- a/cayenne/src/main/java/org/apache/cayenne/access/DataContextMergeHandler.java
+++ b/cayenne/src/main/java/org/apache/cayenne/access/DataContextMergeHandler.java
@@ -157,7 +157,7 @@ class DataContextMergeHandler implements GraphChangeHandler, DataChannelListener
Object oldValue,
Object newValue) {
- Persistent object = context.getObjectStore().getNode(nodeId);
+ Persistent object = context.getObjectStore().getObject(nodeId);
if (object != null && object.getPersistenceState() != PersistenceState.HOLLOW) {
// do not override local changes....
@@ -181,7 +181,7 @@ class DataContextMergeHandler implements GraphChangeHandler, DataChannelListener
// works the same for add and remove as long as we don't get too smart per TODO below.
private void arcChanged(Object nodeId, Object arcId) {
- final Persistent source = context.getObjectStore().getNode(nodeId);
+ final Persistent source = context.getObjectStore().getObject(nodeId);
if (source != null && source.getPersistenceState() != PersistenceState.HOLLOW) {
final int state = source.getPersistenceState();
diff --git a/cayenne/src/main/java/org/apache/cayenne/access/DataContextObjectStore.java b/cayenne/src/main/java/org/apache/cayenne/access/DataContextObjectStore.java
index 9c0455af3..0a17b0f3a 100644
--- a/cayenne/src/main/java/org/apache/cayenne/access/DataContextObjectStore.java
+++ b/cayenne/src/main/java/org/apache/cayenne/access/DataContextObjectStore.java
@@ -64,7 +64,7 @@ import java.util.concurrent.ConcurrentHashMap;
* {@link ObjectStore} of a {@link DataContext}. Stores objects using their ObjectId as a key and keeps their
* committed snapshots in sync with the shared {@link DataRowStore}.
*
- * @since 5.0 renamed from ObjectStore
+ * @since 5.0
*/
public class DataContextObjectStore implements ObjectStore, SnapshotEventListener {
@@ -468,7 +468,7 @@ public class DataContextObjectStore implements ObjectStore, SnapshotEventListene
DataContextObjectStore parentStore = parent.getObjectStore();
EntityInheritanceTree inheritanceTree = parent.getEntityResolver().getInheritanceTree(oid.getEntityName());
for (ObjectId candidateId : inheritanceTree.polymorphicIds(oid)) {
- Persistent parentObject = parentStore.getNode(candidateId);
+ Persistent parentObject = parentStore.getObject(candidateId);
if (parentObject != null) {
return parent.currentSnapshot(parentObject);
}
@@ -618,7 +618,7 @@ public class DataContextObjectStore implements ObjectStore, SnapshotEventListene
if (delegate.shouldProcessDelete(object)) {
object.setPersistenceState(PersistenceState.NEW);
changes.remove(nodeId);
- registerNode(nodeId, object);
+ registerObject(nodeId, object);
nodeCreated(nodeId);
delegate.finishedProcessDelete(object);
}
@@ -633,7 +633,7 @@ public class DataContextObjectStore implements ObjectStore, SnapshotEventListene
void processInvalidatedIDs(Collection<ObjectId> invalidatedIDs) {
if (invalidatedIDs != null && !invalidatedIDs.isEmpty()) {
for (ObjectId oid : invalidatedIDs) {
- Persistent object = (Persistent) getNode(oid);
+ Persistent object = (Persistent) getObject(oid);
if (object == null) {
continue;
@@ -785,7 +785,7 @@ public class DataContextObjectStore implements ObjectStore, SnapshotEventListene
* @since 1.2
*/
@Override
- public synchronized Persistent getNode(Object nodeId) {
+ public synchronized Persistent getObject(Object nodeId) {
return objectMap.get(nodeId);
}
@@ -796,7 +796,7 @@ public class DataContextObjectStore implements ObjectStore, SnapshotEventListene
* @since 1.2
*/
@Override
- public synchronized Collection<Persistent> registeredNodes() {
+ public synchronized Collection<Persistent> registeredObjects() {
return new ArrayList<>(objectMap.values());
}
@@ -804,7 +804,7 @@ public class DataContextObjectStore implements ObjectStore, SnapshotEventListene
* @since 1.2
*/
@Override
- public synchronized void registerNode(Object nodeId, Persistent nodeObject) {
+ public synchronized void registerObject(Object nodeId, Persistent nodeObject) {
objectMap.put(nodeId, nodeObject);
}
@@ -812,7 +812,7 @@ public class DataContextObjectStore implements ObjectStore, SnapshotEventListene
* @since 1.2
*/
@Override
- public synchronized Persistent unregisterNode(Object nodeId) {
+ public synchronized Persistent unregisterObject(Object nodeId) {
Persistent object = objectMap.get(nodeId);
if (object != null) {
objectsUnregistered(Collections.singleton(object));
diff --git a/cayenne/src/main/java/org/apache/cayenne/access/JoinedIdParentAttachmentStrategy.java b/cayenne/src/main/java/org/apache/cayenne/access/JoinedIdParentAttachmentStrategy.java
index db5844af3..9f21585c7 100644
--- a/cayenne/src/main/java/org/apache/cayenne/access/JoinedIdParentAttachmentStrategy.java
+++ b/cayenne/src/main/java/org/apache/cayenne/access/JoinedIdParentAttachmentStrategy.java
@@ -70,7 +70,7 @@ class JoinedIdParentAttachmentStrategy implements ParentAttachmentStrategy {
, row, entity.getName(), relatedIdPrefix);
}
- parentObject = objectStore.getNode(id);
+ parentObject = objectStore.getObject(id);
if (parentObject != null) {
break;
}
diff --git a/cayenne/src/main/java/org/apache/cayenne/access/ObjectStoreGraphDiff.java b/cayenne/src/main/java/org/apache/cayenne/access/ObjectStoreGraphDiff.java
index 7db703b85..40547dfdf 100644
--- a/cayenne/src/main/java/org/apache/cayenne/access/ObjectStoreGraphDiff.java
+++ b/cayenne/src/main/java/org/apache/cayenne/access/ObjectStoreGraphDiff.java
@@ -183,7 +183,7 @@ public class ObjectStoreGraphDiff implements GraphDiff {
ObjectId id = (ObjectId) entry.getKey();
- Persistent object = objectStore.getNode(id);
+ Persistent object = objectStore.getObject(id);
// address manual id override.
ObjectId objectId = object.getObjectId();
diff --git a/cayenne/src/main/java/org/apache/cayenne/access/flush/DbRowOpFactory.java b/cayenne/src/main/java/org/apache/cayenne/access/flush/DbRowOpFactory.java
index 90f461ef4..7fa45bce8 100644
--- a/cayenne/src/main/java/org/apache/cayenne/access/flush/DbRowOpFactory.java
+++ b/cayenne/src/main/java/org/apache/cayenne/access/flush/DbRowOpFactory.java
@@ -74,7 +74,7 @@ class DbRowOpFactory {
ObjectId id = (ObjectId) diff.getNodeId();
this.diff = diff;
this.descriptor = resolver.getClassDescriptor(id.getEntityName());
- this.object = store.getNode(id);
+ this.object = store.getObject(id);
this.dbRows.clear();
}
@@ -99,7 +99,7 @@ class DbRowOpFactory {
private DbRowOp createRow(DbEntity entity, ObjectId id, DbRowOpType type) {
// skip phantom nodes, this could be a created and immediately deleted relationship
- if (store.getNode(id) == null && !id.getEntityName().startsWith("db:")) {
+ if (store.getObject(id) == null && !id.getEntityName().startsWith("db:")) {
return null;
}
switch (type) {
diff --git a/cayenne/src/main/java/org/apache/cayenne/ashwood/AshwoodEntitySorter.java b/cayenne/src/main/java/org/apache/cayenne/ashwood/AshwoodEntitySorter.java
index 7ce3339d2..22cdffd85 100644
--- a/cayenne/src/main/java/org/apache/cayenne/ashwood/AshwoodEntitySorter.java
+++ b/cayenne/src/main/java/org/apache/cayenne/ashwood/AshwoodEntitySorter.java
@@ -289,7 +289,7 @@ public class AshwoodEntitySorter implements EntitySorter {
// not using 'localObject', looking up in context instead, as within the sorter
// we only care about objects participating in transaction, so no need to create hollow objects
- return (id != null) ? context.getObjectStore().getNode(id) : null;
+ return (id != null) ? context.getObjectStore().getObject(id) : null;
}
@Override
diff --git a/cayenne/src/main/java/org/apache/cayenne/graph/ChildDiffLoader.java b/cayenne/src/main/java/org/apache/cayenne/graph/ChildDiffLoader.java
index e61713b02..639b5f719 100644
--- a/cayenne/src/main/java/org/apache/cayenne/graph/ChildDiffLoader.java
+++ b/cayenne/src/main/java/org/apache/cayenne/graph/ChildDiffLoader.java
@@ -243,7 +243,7 @@ public class ChildDiffLoader implements GraphChangeHandler {
// return it;
// if not - fetch.
- Persistent object = context.getObjectStore().getNode(nodeId);
+ Persistent object = context.getObjectStore().getObject(nodeId);
if (object != null) {
return object;
}
diff --git a/cayenne/src/main/java/org/apache/cayenne/tx/DataChannelSyncCallbackAction.java b/cayenne/src/main/java/org/apache/cayenne/tx/DataChannelSyncCallbackAction.java
index 5258f4320..8951fdf61 100644
--- a/cayenne/src/main/java/org/apache/cayenne/tx/DataChannelSyncCallbackAction.java
+++ b/cayenne/src/main/java/org/apache/cayenne/tx/DataChannelSyncCallbackAction.java
@@ -91,7 +91,7 @@ abstract class DataChannelSyncCallbackAction implements GraphChangeHandler {
Op op = seenIds.put(nodeId, Op.INSERT);
if (op == null) {
- Object node = objectStore.getNode(nodeId);
+ Object node = objectStore.getObject(nodeId);
if (node != null) {
if (persisted == null) {
@@ -110,7 +110,7 @@ abstract class DataChannelSyncCallbackAction implements GraphChangeHandler {
// the node may have been updated prior to delete
if (op != Op.DELETE) {
- Object node = objectStore.getNode(nodeId);
+ Object node = objectStore.getObject(nodeId);
if (node != null) {
if (removed == null) {
@@ -155,7 +155,7 @@ abstract class DataChannelSyncCallbackAction implements GraphChangeHandler {
if (op == null) {
- Object node = objectStore.getNode(nodeId);
+ Object node = objectStore.getObject(nodeId);
if (node != null) {
if (updated == null) {
diff --git a/cayenne/src/main/java/org/apache/cayenne/util/ShallowMergeOperation.java b/cayenne/src/main/java/org/apache/cayenne/util/ShallowMergeOperation.java
index d13a7066f..609dd0729 100644
--- a/cayenne/src/main/java/org/apache/cayenne/util/ShallowMergeOperation.java
+++ b/cayenne/src/main/java/org/apache/cayenne/util/ShallowMergeOperation.java
@@ -59,7 +59,7 @@ public class ShallowMergeOperation {
// have to synchronize almost the entire method to prevent multiple threads from
// messing up Persistent objects per CAY-845.
synchronized (objectStore) {
- T object = (T) objectStore.getNode(id);
+ T object = (T) objectStore.getObject(id);
// merge into an existing object
if (object == null) {
@@ -74,7 +74,7 @@ public class ShallowMergeOperation {
object.setPersistenceState(PersistenceState.COMMITTED);
}
- objectStore.registerNode(id, object);
+ objectStore.registerObject(id, object);
}
// TODO: Andrus, 1/24/2006 implement smart merge for modified objects...
diff --git a/cayenne/src/test/java/org/apache/cayenne/CayenneIT.java b/cayenne/src/test/java/org/apache/cayenne/CayenneIT.java
index d172b6a75..a4dae5cda 100644
--- a/cayenne/src/test/java/org/apache/cayenne/CayenneIT.java
+++ b/cayenne/src/test/java/org/apache/cayenne/CayenneIT.java
@@ -140,7 +140,7 @@ public class CayenneIT {
ObjectId id = ObjectId.of("Artist", Artist.ARTIST_ID_PK_COLUMN, 33002);
- assertNull(env.context().getObjectStore().getNode(id));
+ assertNull(env.context().getObjectStore().getObject(id));
ObjectSelect<Artist> query = ObjectSelect.query(Artist.class).where(Artist.SELF.eqId(id));
Object object = Cayenne.objectForQuery(env.context(), query);
diff --git a/cayenne/src/test/java/org/apache/cayenne/CayennePersistentObjectInContextIT.java b/cayenne/src/test/java/org/apache/cayenne/CayennePersistentObjectInContextIT.java
index 8caae2d40..c3dc069d3 100644
--- a/cayenne/src/test/java/org/apache/cayenne/CayennePersistentObjectInContextIT.java
+++ b/cayenne/src/test/java/org/apache/cayenne/CayennePersistentObjectInContextIT.java
@@ -66,7 +66,7 @@ public class CayennePersistentObjectInContextIT {
// double registration in the same context should be quietly ignored
context.registerNewObject(object);
assertSame(tempID, object.getObjectId());
- assertSame(object, context.getObjectStore().getNode(tempID));
+ assertSame(object, context.getObjectStore().getObject(tempID));
// registering in another context should throw an exception
ObjectContext anotherContext = runtime.newContext();
@@ -176,7 +176,7 @@ public class CayennePersistentObjectInContextIT {
context.commitChanges();
assertEquals(PersistenceState.TRANSIENT, o1.getPersistenceState());
- assertFalse(context.getObjectStore().registeredNodes().contains(o1));
+ assertFalse(context.getObjectStore().registeredObjects().contains(o1));
assertNull(o1.getObjectContext());
}
@@ -214,7 +214,7 @@ public class CayennePersistentObjectInContextIT {
assertNotNull(a1);
assertNotNull(a2);
- assertEquals(1, context.getObjectStore().registeredNodes().size());
+ assertEquals(1, context.getObjectStore().registeredObjects().size());
assertSame(a1, a2);
}
diff --git a/cayenne/src/test/java/org/apache/cayenne/access/DataContextExtrasIT.java b/cayenne/src/test/java/org/apache/cayenne/access/DataContextExtrasIT.java
index d2730c3d3..c8baa65e4 100644
--- a/cayenne/src/test/java/org/apache/cayenne/access/DataContextExtrasIT.java
+++ b/cayenne/src/test/java/org/apache/cayenne/access/DataContextExtrasIT.java
@@ -106,7 +106,7 @@ public class DataContextExtrasIT {
context.commitChanges();
assertEquals(PersistenceState.COMMITTED, object.getPersistenceState());
- assertSame(object, context.getObjectStore().getNode(manualId));
+ assertSame(object, context.getObjectStore().getObject(manualId));
assertEquals(manualId, object.getObjectId());
}
@@ -188,7 +188,7 @@ public class DataContextExtrasIT {
public void newObject() {
Artist a1 = (Artist) context.newObject("Artist");
- assertTrue(context.getObjectStore().registeredNodes().contains(a1));
+ assertTrue(context.getObjectStore().registeredObjects().contains(a1));
assertTrue(context.newObjects().contains(a1));
}
@@ -196,7 +196,7 @@ public class DataContextExtrasIT {
public void newObjectWithClass() {
Artist a1 = context.newObject(Artist.class);
- assertTrue(context.getObjectStore().registeredNodes().contains(a1));
+ assertTrue(context.getObjectStore().registeredObjects().contains(a1));
assertTrue(context.newObjects().contains(a1));
}
@@ -207,7 +207,7 @@ public class DataContextExtrasIT {
row.put("ARTIST_ID", 100000);
Persistent obj = context.objectFromDataRow(Artist.class, row);
assertNotNull(obj);
- assertTrue(context.getObjectStore().registeredNodes().contains(obj));
+ assertTrue(context.getObjectStore().registeredObjects().contains(obj));
assertEquals(PersistenceState.HOLLOW, obj.getPersistenceState());
assertNull(context.getObjectStore().getCachedSnapshot(obj.getObjectId()));
@@ -221,7 +221,7 @@ public class DataContextExtrasIT {
row.put("ARTIST_NAME", "ArtistXYZ");
Persistent obj = context.objectFromDataRow(Artist.class, row);
assertNotNull(obj);
- assertTrue(context.getObjectStore().registeredNodes().contains(obj));
+ assertTrue(context.getObjectStore().registeredObjects().contains(obj));
assertEquals(PersistenceState.HOLLOW, obj.getPersistenceState());
assertNull(context.getObjectStore().getCachedSnapshot(obj.getObjectId()));
}
@@ -235,7 +235,7 @@ public class DataContextExtrasIT {
row.put("DATE_OF_BIRTH", new Date());
Artist obj = context.objectFromDataRow(Artist.class, row);
- assertTrue(context.getObjectStore().registeredNodes().contains(obj));
+ assertTrue(context.getObjectStore().registeredObjects().contains(obj));
assertEquals(PersistenceState.COMMITTED, obj.getPersistenceState());
assertNotNull(context.getObjectStore().getCachedSnapshot(obj.getObjectId()));
assertEquals("ArtistXYZ", obj.getArtistName());
diff --git a/cayenne/src/test/java/org/apache/cayenne/access/DataContextIT.java b/cayenne/src/test/java/org/apache/cayenne/access/DataContextIT.java
index 36a8735a3..3170bc7eb 100644
--- a/cayenne/src/test/java/org/apache/cayenne/access/DataContextIT.java
+++ b/cayenne/src/test/java/org/apache/cayenne/access/DataContextIT.java
@@ -575,16 +575,16 @@ public class DataContextIT {
ObjectId oid = object.getObjectId();
// insert object into the ObjectStore
- context.getObjectStore().registerNode(oid, object);
+ context.getObjectStore().registerObject(oid, object);
- assertSame(object, context.getObjectStore().getNode(oid));
+ assertSame(object, context.getObjectStore().getObject(oid));
assertNotNull(context.getObjectStore().getCachedSnapshot(oid));
context.invalidateObjects(object);
assertSame(oid, object.getObjectId());
assertNull(context.getObjectStore().getCachedSnapshot(oid));
- assertSame(object, context.getObjectStore().getNode(oid));
+ assertSame(object, context.getObjectStore().getObject(oid));
}
@Test
@@ -598,16 +598,16 @@ public class DataContextIT {
ObjectId oid = object.getObjectId();
// insert object into the ObjectStore
- context.getObjectStore().registerNode(oid, object);
+ context.getObjectStore().registerObject(oid, object);
- assertSame(object, context.getObjectStore().getNode(oid));
+ assertSame(object, context.getObjectStore().getObject(oid));
assertNotNull(context.getObjectStore().getCachedSnapshot(oid));
context.invalidateObjects(Collections.singleton(object));
assertSame(oid, object.getObjectId());
assertNull(context.getObjectStore().getCachedSnapshot(oid));
- assertSame(object, context.getObjectStore().getNode(oid));
+ assertSame(object, context.getObjectStore().getObject(oid));
}
@Test
@@ -620,7 +620,7 @@ public class DataContextIT {
// testing this...
context.deleteObjects(hollow);
- assertSame(hollow, context.getObjectStore().getNode(ObjectId.of("Artist", "ARTIST_ID", 33001)));
+ assertSame(hollow, context.getObjectStore().getObject(ObjectId.of("Artist", "ARTIST_ID", 33001)));
assertEquals("artist1", hollow.getArtistName());
assertEquals(PersistenceState.DELETED, hollow.getPersistenceState());
diff --git a/cayenne/src/test/java/org/apache/cayenne/access/DataContextIdQueryIT.java b/cayenne/src/test/java/org/apache/cayenne/access/DataContextIdQueryIT.java
index 612ec5927..6600d287b 100644
--- a/cayenne/src/test/java/org/apache/cayenne/access/DataContextIdQueryIT.java
+++ b/cayenne/src/test/java/org/apache/cayenne/access/DataContextIdQueryIT.java
@@ -173,7 +173,7 @@ public class DataContextIdQueryIT {
assertEquals("a1", a.getArtistName());
// the object was resolved via the parent, so the parent has it too
- assertNotNull(context.getObjectStore().getNode(artistId(1)));
+ assertNotNull(context.getObjectStore().getObject(artistId(1)));
}
@Test
diff --git a/cayenne/src/test/java/org/apache/cayenne/access/DataContextObjectStoreIT.java b/cayenne/src/test/java/org/apache/cayenne/access/DataContextObjectStoreIT.java
index a834e706a..eda6f0e69 100644
--- a/cayenne/src/test/java/org/apache/cayenne/access/DataContextObjectStoreIT.java
+++ b/cayenne/src/test/java/org/apache/cayenne/access/DataContextObjectStoreIT.java
@@ -52,19 +52,19 @@ public class DataContextObjectStoreIT {
Persistent o1 = new MockPersistentObject();
o1.setObjectId(ObjectId.of("T", "key1", "v1"));
- env.context().getObjectStore().registerNode(o1.getObjectId(), o1);
+ env.context().getObjectStore().registerObject(o1.getObjectId(), o1);
assertEquals(1, env.context().getObjectStore().registeredObjectsCount());
// test object with same id
Persistent o2 = new MockPersistentObject();
o2.setObjectId(ObjectId.of("T", "key1", "v1"));
- env.context().getObjectStore().registerNode(o2.getObjectId(), o2);
+ env.context().getObjectStore().registerObject(o2.getObjectId(), o2);
assertEquals(1, env.context().getObjectStore().registeredObjectsCount());
// test new object
Persistent o3 = new MockPersistentObject();
o3.setObjectId(ObjectId.of("T", "key3", "v3"));
- env.context().getObjectStore().registerNode(o3.getObjectId(), o3);
+ env.context().getObjectStore().registerObject(o3.getObjectId(), o3);
assertEquals(2, env.context().getObjectStore().registeredObjectsCount());
}
@@ -79,14 +79,14 @@ public class DataContextObjectStoreIT {
ObjectId oid = object.getObjectId();
// insert object into the ObjectStore
- env.context().getObjectStore().registerNode(oid, object);
- assertSame(object, env.context().getObjectStore().getNode(oid));
+ env.context().getObjectStore().registerObject(oid, object);
+ assertSame(object, env.context().getObjectStore().getObject(oid));
assertNotNull(env.context().getObjectStore().getCachedSnapshot(oid));
env.context().getObjectStore().objectsUnregistered(Collections.singletonList(object));
assertEquals(oid, object.getObjectId());
- assertNull(env.context().getObjectStore().getNode(oid));
+ assertNull(env.context().getObjectStore().getObject(oid));
// in the future this may not be the case
assertNull(env.context().getObjectStore().getCachedSnapshot(oid));
diff --git a/cayenne/src/test/java/org/apache/cayenne/access/DataContextObjectStoreTest.java b/cayenne/src/test/java/org/apache/cayenne/access/DataContextObjectStoreTest.java
index ab10e2c1b..1cc78f26a 100644
--- a/cayenne/src/test/java/org/apache/cayenne/access/DataContextObjectStoreTest.java
+++ b/cayenne/src/test/java/org/apache/cayenne/access/DataContextObjectStoreTest.java
@@ -48,23 +48,23 @@ public class DataContextObjectStoreTest {
}
@Test
- public void registerNode() {
+ public void registerObject() {
ObjectId id = ObjectId.of("E1", "ID", 500);
Persistent object = mock(Persistent.class);
- objectStore.registerNode(id, object);
- assertSame(object, objectStore.getNode(id));
+ objectStore.registerObject(id, object);
+ assertSame(object, objectStore.getObject(id));
}
@Test
- public void unregisterNode() {
+ public void unregisterObject() {
ObjectId id = ObjectId.of("E1", "ID", 500);
Persistent object = mock(Persistent.class);
- objectStore.registerNode(id, object);
- Object unregistered = objectStore.unregisterNode(id);
+ objectStore.registerObject(id, object);
+ Object unregistered = objectStore.unregisterObject(id);
assertSame(object, unregistered);
verify(object, times(0)).setObjectId(null);
diff --git a/cayenne/src/test/java/org/apache/cayenne/access/DataContextObjectTrackingIT.java b/cayenne/src/test/java/org/apache/cayenne/access/DataContextObjectTrackingIT.java
index b62361c84..76a882075 100644
--- a/cayenne/src/test/java/org/apache/cayenne/access/DataContextObjectTrackingIT.java
+++ b/cayenne/src/test/java/org/apache/cayenne/access/DataContextObjectTrackingIT.java
@@ -97,14 +97,14 @@ public class DataContextObjectTrackingIT {
assertEquals(PersistenceState.COMMITTED, obj.getPersistenceState());
assertSame(context, obj.getObjectContext());
- assertSame(obj, context.getObjectStore().getNode(oid));
+ assertSame(obj, context.getObjectStore().getObject(oid));
context.unregisterObjects(Collections.singletonList(obj));
assertEquals(PersistenceState.TRANSIENT, obj.getPersistenceState());
assertNull(obj.getObjectContext());
assertEquals(oid, obj.getObjectId());
- assertNull(context.getObjectStore().getNode(oid));
+ assertNull(context.getObjectStore().getObject(oid));
assertNull(context.getObjectStore().getCachedSnapshot(oid));
}
@@ -120,7 +120,7 @@ public class DataContextObjectTrackingIT {
assertEquals(PersistenceState.COMMITTED, obj.getPersistenceState());
assertSame(context, obj.getObjectContext());
- assertSame(obj, context.getObjectStore().getNode(oid));
+ assertSame(obj, context.getObjectStore().getObject(oid));
context.invalidateObjects(obj);
@@ -128,6 +128,6 @@ public class DataContextObjectTrackingIT {
assertSame(context, obj.getObjectContext());
assertSame(oid, obj.getObjectId());
assertNull(context.getObjectStore().getCachedSnapshot(oid));
- assertNotNull(context.getObjectStore().getNode(oid));
+ assertNotNull(context.getObjectStore().getObject(oid));
}
}
diff --git a/cayenne/src/test/java/org/apache/cayenne/access/DataContextPrefetchMultistepIT.java b/cayenne/src/test/java/org/apache/cayenne/access/DataContextPrefetchMultistepIT.java
index 6c2a9d688..51e97a47d 100644
--- a/cayenne/src/test/java/org/apache/cayenne/access/DataContextPrefetchMultistepIT.java
+++ b/cayenne/src/test/java/org/apache/cayenne/access/DataContextPrefetchMultistepIT.java
@@ -121,8 +121,8 @@ public class DataContextPrefetchMultistepIT {
id2.put("EXHIBIT_ID", 2);
ObjectId oid2 = ObjectId.of("ArtistExhibit", id2);
- assertNull(context.getObjectStore().getNode(oid1));
- assertNull(context.getObjectStore().getNode(oid2));
+ assertNull(context.getObjectStore().getObject(oid1));
+ assertNull(context.getObjectStore().getObject(oid2));
List<Gallery> galleries = ObjectSelect.query(Gallery.class)
.where(Gallery.GALLERY_NAME.eq("gallery2"))
@@ -137,8 +137,8 @@ public class DataContextPrefetchMultistepIT {
assertTrue(list instanceof Fault);
// however the target objects must be resolved
- ArtistExhibit ae1 = (ArtistExhibit) context.getObjectStore().getNode(oid1);
- ArtistExhibit ae2 = (ArtistExhibit) context.getObjectStore().getNode(oid2);
+ ArtistExhibit ae1 = (ArtistExhibit) context.getObjectStore().getObject(oid1);
+ ArtistExhibit ae2 = (ArtistExhibit) context.getObjectStore().getObject(oid2);
assertNotNull(ae1);
assertNotNull(ae2);
diff --git a/cayenne/src/test/java/org/apache/cayenne/access/JointPrefetchIT.java b/cayenne/src/test/java/org/apache/cayenne/access/JointPrefetchIT.java
index 762cb1482..89a745b86 100644
--- a/cayenne/src/test/java/org/apache/cayenne/access/JointPrefetchIT.java
+++ b/cayenne/src/test/java/org/apache/cayenne/access/JointPrefetchIT.java
@@ -343,7 +343,7 @@ public class JointPrefetchIT {
final DataContext context = this.context;
// sanity check...
- Persistent g1 = (Persistent) context.getObjectStore().getNode(
+ Persistent g1 = (Persistent) context.getObjectStore().getObject(
ObjectId.of("Gallery", Gallery.GALLERY_ID_PK_COLUMN, 33001));
assertNull(g1);
@@ -365,11 +365,11 @@ public class JointPrefetchIT {
}
// however both galleries must be in memory...
- Persistent g11 = (Persistent) context.getObjectStore().getNode(
+ Persistent g11 = (Persistent) context.getObjectStore().getObject(
ObjectId.of("Gallery", Gallery.GALLERY_ID_PK_COLUMN, 33001));
assertNotNull(g11);
assertEquals(PersistenceState.COMMITTED, g11.getPersistenceState());
- Persistent g2 = (Persistent) context.getObjectStore().getNode(
+ Persistent g2 = (Persistent) context.getObjectStore().getObject(
ObjectId.of("Gallery", Gallery.GALLERY_ID_PK_COLUMN, 33002));
assertNotNull(g2);
assertEquals(PersistenceState.COMMITTED, g2.getPersistenceState());
@@ -418,7 +418,7 @@ public class JointPrefetchIT {
.addPrefetch(Artist.PAINTING_ARRAY.dot(Painting.TO_GALLERY).joint())
.select(context);
env.runWithQueriesBlocked(() -> {
- Persistent g1 = (Persistent) context.getObjectStore().getNode(
+ Persistent g1 = (Persistent) context.getObjectStore().getObject(
ObjectId.of("Gallery", Gallery.GALLERY_ID_PK_COLUMN, 33001)
);
assertNotNull(g1);
diff --git a/cayenne/src/test/java/org/apache/cayenne/access/NestedDataContextParentEventsIT.java b/cayenne/src/test/java/org/apache/cayenne/access/NestedDataContextParentEventsIT.java
index 7f5034c1d..0a0b45280 100644
--- a/cayenne/src/test/java/org/apache/cayenne/access/NestedDataContextParentEventsIT.java
+++ b/cayenne/src/test/java/org/apache/cayenne/access/NestedDataContextParentEventsIT.java
@@ -46,7 +46,7 @@ public class NestedDataContextParentEventsIT {
ac.setArtistName("X");
child1.commitChangesToParent();
- final Artist ap = (Artist) env.context().getObjectStore().getNode(ac.getObjectId());
+ final Artist ap = (Artist) env.context().getObjectStore().getObject(ac.getObjectId());
assertNotNull(ap);
assertTrue(ap.getObjectId().isTemporary());
diff --git a/cayenne/src/test/java/org/apache/cayenne/access/NestedDataContextReadIT.java b/cayenne/src/test/java/org/apache/cayenne/access/NestedDataContextReadIT.java
index 4dc4c66c7..c082c5298 100644
--- a/cayenne/src/test/java/org/apache/cayenne/access/NestedDataContextReadIT.java
+++ b/cayenne/src/test/java/org/apache/cayenne/access/NestedDataContextReadIT.java
@@ -348,7 +348,7 @@ public class NestedDataContextReadIT {
assertEquals(PersistenceState.COMMITTED, artist.getPersistenceState());
assertSame(childContext, artist.getObjectContext());
- Object parentArtist = context.getObjectStore().getNode(artist.getObjectId());
+ Object parentArtist = context.getObjectStore().getObject(artist.getObjectId());
assertNotNull(parentArtist);
assertNotSame(artist, parentArtist);
}
diff --git a/cayenne/src/test/java/org/apache/cayenne/access/NestedDataContextWriteIT.java b/cayenne/src/test/java/org/apache/cayenne/access/NestedDataContextWriteIT.java
index 23c0c2820..7f37f7f46 100644
--- a/cayenne/src/test/java/org/apache/cayenne/access/NestedDataContextWriteIT.java
+++ b/cayenne/src/test/java/org/apache/cayenne/access/NestedDataContextWriteIT.java
@@ -141,7 +141,7 @@ public class NestedDataContextWriteIT {
childContext.commitChangesToParent();
assertEquals(PersistenceState.COMMITTED, childP1.getPersistenceState());
- Painting parentP1 = (Painting) context.getObjectStore().getNode(
+ Painting parentP1 = (Painting) context.getObjectStore().getObject(
childP1.getObjectId());
assertNotNull(parentP1);
@@ -188,13 +188,13 @@ public class NestedDataContextWriteIT {
.getPersistenceState());
assertEquals(PersistenceState.HOLLOW, childHollow.getPersistenceState());
- Artist parentNew = (Artist) context.getObjectStore().getNode(
+ Artist parentNew = (Artist) context.getObjectStore().getObject(
childNew.getObjectId());
- Artist parentModified = (Artist) context.getObjectStore().getNode(
+ Artist parentModified = (Artist) context.getObjectStore().getObject(
childModified.getObjectId());
- Artist parentCommitted = (Artist) context.getObjectStore().getNode(
+ Artist parentCommitted = (Artist) context.getObjectStore().getObject(
childCommitted.getObjectId());
- Artist parentHollow = (Artist) context.getObjectStore().getNode(
+ Artist parentHollow = (Artist) context.getObjectStore().getObject(
childHollow.getObjectId());
assertNotNull(parentNew);
@@ -249,7 +249,7 @@ public class NestedDataContextWriteIT {
assertEquals(PersistenceState.TRANSIENT, childDeleted.getPersistenceState());
- Artist parentDeleted = (Artist) context.getObjectStore().getNode(
+ Artist parentDeleted = (Artist) context.getObjectStore().getObject(
childDeleted.getObjectId());
assertNotNull(parentDeleted);
@@ -294,15 +294,15 @@ public class NestedDataContextWriteIT {
assertEquals(PersistenceState.TRANSIENT, childDeleted.getPersistenceState());
assertEquals(PersistenceState.HOLLOW, childHollow.getPersistenceState());
- Artist parentNew = (Artist) context.getObjectStore().getNode(
+ Artist parentNew = (Artist) context.getObjectStore().getObject(
childNew.getObjectId());
- Artist parentModified = (Artist) context.getObjectStore().getNode(
+ Artist parentModified = (Artist) context.getObjectStore().getObject(
childModified.getObjectId());
- Artist parentCommitted = (Artist) context.getObjectStore().getNode(
+ Artist parentCommitted = (Artist) context.getObjectStore().getObject(
childCommitted.getObjectId());
- Artist parentDeleted = (Artist) context.getObjectStore().getNode(
+ Artist parentDeleted = (Artist) context.getObjectStore().getObject(
childDeleted.getObjectId());
- Artist parentHollow = (Artist) context.getObjectStore().getNode(
+ Artist parentHollow = (Artist) context.getObjectStore().getObject(
childHollow.getObjectId());
assertNotNull(parentNew);
@@ -361,14 +361,14 @@ public class NestedDataContextWriteIT {
assertEquals(PersistenceState.COMMITTED, childModifiedToMany
.getPersistenceState());
- parentModifiedSimple = (Painting) context.getObjectStore().getNode(
+ parentModifiedSimple = (Painting) context.getObjectStore().getObject(
childModifiedSimple.getObjectId());
Painting parentModifiedToOne = (Painting) context
.getObjectStore()
- .getNode(childModifiedToOne.getObjectId());
+ .getObject(childModifiedToOne.getObjectId());
- parentModifiedToMany = (Artist) context.getObjectStore().getNode(
+ parentModifiedToMany = (Artist) context.getObjectStore().getObject(
childModifiedToMany.getObjectId());
assertNotNull(parentModifiedSimple);
@@ -419,7 +419,7 @@ public class NestedDataContextWriteIT {
assertEquals(PersistenceState.COMMITTED, childDetail1
.getPersistenceState());
- Painting parentMaster = (Painting) context.getObjectStore().getNode(
+ Painting parentMaster = (Painting) context.getObjectStore().getObject(
childMaster.getObjectId());
assertNotNull(parentMaster);
@@ -427,7 +427,7 @@ public class NestedDataContextWriteIT {
PaintingInfo parentDetail1 = (PaintingInfo) context
.getObjectStore()
- .getNode(childDetail1.getObjectId());
+ .getObject(childDetail1.getObjectId());
assertNotNull(parentDetail1);
assertEquals(PersistenceState.NEW, parentDetail1.getPersistenceState());
@@ -462,13 +462,13 @@ public class NestedDataContextWriteIT {
assertEquals(PersistenceState.COMMITTED, childO1.getPersistenceState());
assertEquals(PersistenceState.COMMITTED, childO2.getPersistenceState());
- Artist parentO1 = (Artist) context.getObjectStore().getNode(
+ Artist parentO1 = (Artist) context.getObjectStore().getObject(
childO1.getObjectId());
assertNotNull(parentO1);
assertEquals(PersistenceState.NEW, parentO1.getPersistenceState());
- ArtGroup parentO2 = (ArtGroup) context.getObjectStore().getNode(
+ ArtGroup parentO2 = (ArtGroup) context.getObjectStore().getObject(
childO2.getObjectId());
assertNotNull(parentO2);
@@ -509,19 +509,19 @@ public class NestedDataContextWriteIT {
assertEquals(PersistenceState.COMMITTED, childO2.getPersistenceState());
assertEquals(PersistenceState.COMMITTED, childO3.getPersistenceState());
- Artist parentO1 = (Artist) context.getObjectStore().getNode(
+ Artist parentO1 = (Artist) context.getObjectStore().getObject(
childO1.getObjectId());
assertNotNull(parentO1);
assertEquals(PersistenceState.NEW, parentO1.getPersistenceState());
- ArtGroup parentO2 = (ArtGroup) context.getObjectStore().getNode(
+ ArtGroup parentO2 = (ArtGroup) context.getObjectStore().getObject(
childO2.getObjectId());
assertNotNull(parentO2);
assertEquals(PersistenceState.NEW, parentO2.getPersistenceState());
- ArtGroup parentO3 = (ArtGroup) context.getObjectStore().getNode(
+ ArtGroup parentO3 = (ArtGroup) context.getObjectStore().getObject(
childO3.getObjectId());
assertNotNull(parentO3);
@@ -545,19 +545,19 @@ public class NestedDataContextWriteIT {
assertEquals(PersistenceState.COMMITTED, childO2.getPersistenceState());
assertEquals(PersistenceState.COMMITTED, childO3.getPersistenceState());
- Artist parentO1 = (Artist) context.getObjectStore().getNode(
+ Artist parentO1 = (Artist) context.getObjectStore().getObject(
childO1.getObjectId());
assertNotNull(parentO1);
assertEquals(PersistenceState.NEW, parentO1.getPersistenceState());
- ArtGroup parentO2 = (ArtGroup) context.getObjectStore().getNode(
+ ArtGroup parentO2 = (ArtGroup) context.getObjectStore().getObject(
childO2.getObjectId());
assertNotNull(parentO2);
assertEquals(PersistenceState.NEW, parentO2.getPersistenceState());
- ArtGroup parentO3 = (ArtGroup) context.getObjectStore().getNode(
+ ArtGroup parentO3 = (ArtGroup) context.getObjectStore().getObject(
childO3.getObjectId());
assertNotNull(parentO3);
diff --git a/cayenne/src/test/java/org/apache/cayenne/access/NumericTypesIT.java b/cayenne/src/test/java/org/apache/cayenne/access/NumericTypesIT.java
index 9bf5eb99a..6636164e4 100644
--- a/cayenne/src/test/java/org/apache/cayenne/access/NumericTypesIT.java
+++ b/cayenne/src/test/java/org/apache/cayenne/access/NumericTypesIT.java
@@ -334,7 +334,7 @@ public class NumericTypesIT {
"DecimalPKTestEntity",
"DECIMAL_PK",
new BigDecimal("1.25"));
- assertSame(object, context.getObjectStore().getNode(syntheticId));
+ assertSame(object, context.getObjectStore().getObject(syntheticId));
context.deleteObjects(object);
context.commitChanges();
@@ -351,7 +351,7 @@ public class NumericTypesIT {
context.commitChanges();
ObjectId syntheticId = ObjectId.of("DecimalPKTest1", "DECIMAL_PK", 1.25);
- assertSame(object, context.getObjectStore().getNode(syntheticId));
+ assertSame(object, context.getObjectStore().getObject(syntheticId));
}
@Test
(cayenne) 02/02: CAY-3025 ObjectContext to require/return Persistent for all object ops
Posted by aa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cayenne.git
commit 7805a829e5f3bd375cb46c264affeb9b53eb8512
Author: Andrus Adamchik <an...@objectstyle.com>
AuthorDate: Sat Sep 12 16:02:06 2026 -0400
CAY-3025 ObjectContext to require/return Persistent for all object ops
Also replacing Object nodeId with ObjectId
---
RELEASE-NOTES.txt | 1 +
.../org/apache/cayenne/ObjectContextChangeLog.java | 198 -------------
.../main/java/org/apache/cayenne/ObjectStore.java | 13 +-
.../org/apache/cayenne/access/DataContext.java | 12 +-
.../cayenne/access/DataContextDeleteAction.java | 8 +-
.../cayenne/access/DataContextGraphAction.java | 10 +-
.../cayenne/access/DataContextMergeHandler.java | 32 +--
.../cayenne/access/DataContextObjectStore.java | 306 ++++++++-------------
.../access/DefaultObjectMapRetainStrategy.java | 3 +-
.../java/org/apache/cayenne/access/ObjectDiff.java | 28 +-
.../cayenne/access/ObjectMapRetainStrategy.java | 3 +-
.../cayenne/access/ObjectStoreGraphDiff.java | 10 +-
.../cayenne/access/PrefetchProcessorNode.java | 5 +-
.../access/flush/ArcValuesCreationHandler.java | 14 +-
.../flush/DataDomainIndirectDiffBuilder.java | 16 +-
.../cayenne/access/flush/DbRowOpFactory.java | 19 +-
.../access/flush/DefaultDataDomainFlushAction.java | 2 +-
.../access/flush/ValuesCreationHandler.java | 5 +-
.../cayenne/commitlog/DeletedDiffProcessor.java | 3 +-
.../org/apache/cayenne/commitlog/DiffFilter.java | 36 +--
.../apache/cayenne/commitlog/DiffProcessor.java | 32 +--
.../configuration/runtime/DataContextFactory.java | 1 +
.../apache/cayenne/graph/ArcCreateOperation.java | 23 +-
.../apache/cayenne/graph/ArcDeleteOperation.java | 23 +-
.../org/apache/cayenne/graph/ChildDiffLoader.java | 44 ++-
.../apache/cayenne/graph/GraphChangeHandler.java | 13 +-
.../apache/cayenne/graph/GraphDiffCompressor.java | 57 ++--
.../apache/cayenne/graph/NodeCreateOperation.java | 13 +-
.../apache/cayenne/graph/NodeDeleteOperation.java | 13 +-
.../java/org/apache/cayenne/graph/NodeDiff.java | 15 +-
.../cayenne/graph/NodeIdChangeOperation.java | 19 +-
.../cayenne/graph/NodePropertyChangeOperation.java | 13 +-
.../cayenne/tx/DataChannelSyncCallbackAction.java | 33 +--
.../apache/cayenne/ObjectContextChangeLogTest.java | 74 -----
.../org/apache/cayenne/graph/NodeDiffTest.java | 19 +-
35 files changed, 377 insertions(+), 739 deletions(-)
diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt
index 836dea10e..4cc4ff73d 100644
--- a/RELEASE-NOTES.txt
+++ b/RELEASE-NOTES.txt
@@ -31,6 +31,7 @@ CAY-3021 Get rid of ObjectIdQuery
CAY-3022 Cleanup ObjectContext / DataContext query API
CAY-3023 Replace QueryResult with a List of redesigned QueryResultItems
CAY-3024 Replace QueryResponse with List<QueryResultItem>
+CAY-3025 ObjectContext to require/return Persistent for all object ops
Bug Fixes:
diff --git a/cayenne/src/main/java/org/apache/cayenne/ObjectContextChangeLog.java b/cayenne/src/main/java/org/apache/cayenne/ObjectContextChangeLog.java
deleted file mode 100644
index c0fb10efa..000000000
--- a/cayenne/src/main/java/org/apache/cayenne/ObjectContextChangeLog.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/*****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- ****************************************************************/
-
-package org.apache.cayenne;
-
-import org.apache.cayenne.graph.ArcCreateOperation;
-import org.apache.cayenne.graph.ArcDeleteOperation;
-import org.apache.cayenne.graph.CompoundDiff;
-import org.apache.cayenne.graph.GraphDiff;
-import org.apache.cayenne.graph.NodeDiff;
-
-import java.util.AbstractList;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Stores graph operations in the order they were performed, optionally allowing to set
- * named markers.
- *
- * @since 1.2
- */
-class ObjectContextChangeLog {
-
- List<GraphDiff> diffs;
- Map<String, Integer> markers;
-
- ObjectContextChangeLog() {
- reset();
- }
-
- void unregisterNode(Object nodeId) {
- Iterator<?> it = diffs.iterator();
- while (it.hasNext()) {
- Object next = it.next();
-
- if (next instanceof NodeDiff nodeDiff) {
-
- if (nodeId.equals(nodeDiff.getNodeId())) {
- it.remove();
- }
- else if (next instanceof ArcCreateOperation arcCreate) {
- if (nodeId.equals(arcCreate.getTargetNodeId())) {
- it.remove();
- }
- }
- else if (next instanceof ArcDeleteOperation arcDelete) {
- if (nodeId.equals(arcDelete.getTargetNodeId())) {
- it.remove();
- }
- }
- }
- }
- }
-
- void setMarker(String markerTag) {
- markers.put(markerTag, diffs.size());
- }
-
- void removeMarker(String markerTag) {
- markers.remove(markerTag);
- }
-
- /**
- * Returns a combined GraphDiff for all recorded operations.
- */
- GraphDiff getDiffs() {
- return new CompoundDiff(immutableList(0, diffs.size()));
- }
-
- GraphDiff getDiffsAfterMarker(String markerTag) {
- Integer pos = markers.get(markerTag);
- int marker = (pos == null) ? -1 : pos.intValue();
- if (marker < 0) {
- throw new IllegalStateException("No marked position for tag '"
- + markerTag
- + "'");
- }
-
- return new CompoundDiff(immutableList(marker, diffs.size()));
- }
-
- boolean hasMarker(String markerTag) {
- return markers.containsKey(markerTag);
- }
-
- /**
- * "Forgets" all stored operations.
- */
- void reset() {
- // must create a new list instead of clearing an existing one, as the original
- // list may have been exposed via events or "getDiffs", and trimming it is
- // undesirable.
- this.diffs = new ArrayList<>();
- this.markers = new HashMap<>();
- }
-
- int size() {
- return diffs.size();
- }
-
- int sizeAfterMarker(String markerTag) {
- Integer pos = markers.get(markerTag);
- int marker = (pos == null) ? -1 : pos.intValue();
- if (marker < 0) {
- throw new IllegalStateException("No marked position for tag '"
- + markerTag
- + "'");
- }
-
- return diffs.size() - marker;
- }
-
- /**
- * Adds an operation to the list.
- */
- void addOperation(GraphDiff diff) {
- diffs.add(diff);
- }
-
- /**
- * Returns a sublist of the diffs list that shouldn't change when OperationRecorder is
- * cleared or new operations are added.
- */
- private List<GraphDiff> immutableList(int fromIndex, int toIndex) {
- if (toIndex - fromIndex == 0) {
- return Collections.emptyList();
- }
-
- // Assuming that internal diffs list can only grow and can never be trimmed,
- // return sublist will never change - something that callers are expecting
- return Collections.unmodifiableList(new SubList(diffs, fromIndex, toIndex));
- }
-
- // moded Sublist from JDK that doesn't check for co-modification, as the underlying
- // list is guaranteed to only grow and never shrink or be replaced.
- static class SubList extends AbstractList<GraphDiff> {
-
- private List<GraphDiff> list;
- private int offset;
- private int size;
-
- SubList(List<GraphDiff> list, int fromIndex, int toIndex) {
- if (fromIndex < 0) {
- throw new IndexOutOfBoundsException("fromIndex = " + fromIndex);
- }
- if (toIndex > list.size()) {
- throw new IndexOutOfBoundsException("toIndex = " + toIndex);
- }
- if (fromIndex > toIndex) {
- throw new IllegalArgumentException("fromIndex("
- + fromIndex
- + ") > toIndex("
- + toIndex
- + ")");
- }
- this.list = list;
- offset = fromIndex;
- size = toIndex - fromIndex;
- }
-
- @Override
- public GraphDiff get(int index) {
- rangeCheck(index);
- return list.get(index + offset);
- }
-
- @Override
- public int size() {
- return size;
- }
-
- private void rangeCheck(int index) {
- if (index < 0 || index >= size) {
- throw new IndexOutOfBoundsException("Index: " + index + ",Size: " + size);
- }
- }
- }
-}
diff --git a/cayenne/src/main/java/org/apache/cayenne/ObjectStore.java b/cayenne/src/main/java/org/apache/cayenne/ObjectStore.java
index 9be16c664..9d9a61f23 100644
--- a/cayenne/src/main/java/org/apache/cayenne/ObjectStore.java
+++ b/cayenne/src/main/java/org/apache/cayenne/ObjectStore.java
@@ -19,37 +19,34 @@
package org.apache.cayenne;
-import org.apache.cayenne.graph.GraphChangeHandler;
-
import java.util.Collection;
import java.util.List;
/**
* A registry of persistent objects managed by an {@link ObjectContext}, keyed by {@link ObjectId}. Also tracks the
- * committed state of those objects as {@link DataRow} snapshots. Inherited {@link GraphChangeHandler} methods are
- * callbacks for registered objects to notify the store of their changes.
+ * committed state of those objects as {@link DataRow} snapshots.
* <p>
* Users rarely need to access the store directly, as ObjectContext serves as a facade for most of its operations.
*
* @since 5.0
*/
-public interface ObjectStore extends GraphChangeHandler {
+public interface ObjectStore {
/**
* Returns a registered object for the id, or null if no such object is registered.
*/
- Persistent getObject(Object nodeId);
+ Persistent getObject(ObjectId id);
/**
* Registers an object under the id.
*/
- void registerObject(Object nodeId, Persistent nodeObject);
+ void registerObject(ObjectId id, Persistent nodeObject);
/**
* Unregisters an object with the id, forgetting any information associated with it. Returns the unregistered
* object, or null if none was registered.
*/
- Persistent unregisterObject(Object nodeId);
+ Persistent unregisterObject(ObjectId id);
/**
* Returns a copy of the collection of all registered objects.
diff --git a/cayenne/src/main/java/org/apache/cayenne/access/DataContext.java b/cayenne/src/main/java/org/apache/cayenne/access/DataContext.java
index 8c44851c5..c5348e2b4 100644
--- a/cayenne/src/main/java/org/apache/cayenne/access/DataContext.java
+++ b/cayenne/src/main/java/org/apache/cayenne/access/DataContext.java
@@ -154,7 +154,7 @@ public class DataContext implements ObjectContext {
protected DataContext(
DataChannel channel,
DataRowStore snapshotCache,
- Map<Object, Persistent> objectMap,
+ Map<ObjectId, Persistent> objectMap,
boolean syncWithSnapshotCache,
boolean usingSharedSnapshotCache,
boolean validatingObjectsOnCommit,
@@ -594,7 +594,7 @@ public class DataContext implements ObjectContext {
for (Object target : collection) {
if (target instanceof Persistent targetDO) {
registerNewObject(targetDO);
- objectStore.arcCreated(object.getObjectId(), targetDO.getObjectId(), new ArcId(property));
+ objectStore.changeRecorder().arcCreated(object.getObjectId(), targetDO.getObjectId(), new ArcId(property));
}
}
return true;
@@ -606,7 +606,7 @@ public class DataContext implements ObjectContext {
if (target instanceof Persistent targetDO) {
// make sure it is registered
registerNewObject(targetDO);
- objectStore.arcCreated(object.getObjectId(), targetDO.getObjectId(), new ArcId(property));
+ objectStore.changeRecorder().arcCreated(object.getObjectId(), targetDO.getObjectId(), new ArcId(property));
}
return true;
}
@@ -630,7 +630,7 @@ public class DataContext implements ObjectContext {
synchronized (objectStore) {
objectStore.registerObject(object.getObjectId(), object);
- objectStore.nodeCreated(object.getObjectId());
+ objectStore.changeRecorder().nodeCreated(object.getObjectId());
}
ObjEntity entity;
@@ -1231,7 +1231,7 @@ public class DataContext implements ObjectContext {
private final DataChannel channel;
private DataRowStore snapshotCache;
- private Map<Object, Persistent> objectMap;
+ private Map<ObjectId, Persistent> objectMap;
private boolean syncWithSnapshotCache;
private Boolean usingSharedSnapshotCache;
private boolean validatingObjectsOnCommit = true;
@@ -1254,7 +1254,7 @@ public class DataContext implements ObjectContext {
* Sets a map to store registered objects in. The map determines how strongly the context retains objects.
* Default is a map with weak references to the values.
*/
- public Builder objectMap(Map<Object, Persistent> objectMap) {
+ public Builder objectMap(Map<ObjectId, Persistent> objectMap) {
this.objectMap = objectMap;
return this;
}
diff --git a/cayenne/src/main/java/org/apache/cayenne/access/DataContextDeleteAction.java b/cayenne/src/main/java/org/apache/cayenne/access/DataContextDeleteAction.java
index b118d19e7..097e33a47 100644
--- a/cayenne/src/main/java/org/apache/cayenne/access/DataContextDeleteAction.java
+++ b/cayenne/src/main/java/org/apache/cayenne/access/DataContextDeleteAction.java
@@ -47,9 +47,9 @@ import java.util.Map;
*/
class DataContextDeleteAction {
- private final ObjectContext context;
+ private final DataContext context;
- DataContextDeleteAction(ObjectContext context) {
+ DataContextDeleteAction(DataContext context) {
this.context = context;
}
@@ -106,7 +106,7 @@ class DataContextDeleteAction {
int oldState = object.getPersistenceState();
object.setPersistenceState(PersistenceState.DELETED);
processDeleteRules(object, oldState);
- context.getObjectStore().nodeRemoved(object.getObjectId());
+ context.getObjectStore().changeRecorder().nodeRemoved(object.getObjectId());
}
@SuppressWarnings("unchecked")
@@ -163,7 +163,7 @@ class DataContextDeleteAction {
if (processFlattened) {
ArcId arcId = new ArcId(property);
for (Persistent relatedObject : relatedObjects) {
- context.getObjectStore()
+ context.getObjectStore().changeRecorder()
.arcDeleted(object.getObjectId(), relatedObject.getObjectId(), arcId);
}
}
diff --git a/cayenne/src/main/java/org/apache/cayenne/access/DataContextGraphAction.java b/cayenne/src/main/java/org/apache/cayenne/access/DataContextGraphAction.java
index bdff7b09f..1c1497212 100644
--- a/cayenne/src/main/java/org/apache/cayenne/access/DataContextGraphAction.java
+++ b/cayenne/src/main/java/org/apache/cayenne/access/DataContextGraphAction.java
@@ -30,9 +30,9 @@ import org.apache.cayenne.reflect.PropertyDescriptor;
class DataContextGraphAction {
- private final ObjectContext context;
+ private final DataContext context;
- public DataContextGraphAction(ObjectContext context) {
+ public DataContextGraphAction(DataContext context) {
this.context = context;
}
@@ -70,14 +70,14 @@ class DataContextGraphAction {
markAsDirty(object);
if (oldValue instanceof Persistent) {
- context.getObjectStore().arcDeleted(
+ context.getObjectStore().changeRecorder().arcDeleted(
object.getObjectId(),
((Persistent) oldValue).getObjectId(),
new ArcId(property));
}
if (newValue instanceof Persistent) {
- context.getObjectStore().arcCreated(
+ context.getObjectStore().changeRecorder().arcCreated(
object.getObjectId(),
((Persistent) newValue).getObjectId(),
new ArcId(property));
@@ -91,7 +91,7 @@ class DataContextGraphAction {
Object oldValue,
Object newValue) {
- context.getObjectStore().nodePropertyChanged(
+ context.getObjectStore().changeRecorder().nodePropertyChanged(
object.getObjectId(),
propertyName,
oldValue,
diff --git a/cayenne/src/main/java/org/apache/cayenne/access/DataContextMergeHandler.java b/cayenne/src/main/java/org/apache/cayenne/access/DataContextMergeHandler.java
index 11c6c839b..9ab3c42a2 100644
--- a/cayenne/src/main/java/org/apache/cayenne/access/DataContextMergeHandler.java
+++ b/cayenne/src/main/java/org/apache/cayenne/access/DataContextMergeHandler.java
@@ -76,9 +76,9 @@ class DataContextMergeHandler implements GraphChangeHandler, DataChannelListener
// extra safegurad
}
- private PropertyDescriptor propertyForId(Object nodeId, String propertyName) {
+ private PropertyDescriptor propertyForId(ObjectId id, String propertyName) {
ClassDescriptor descriptor = context.getEntityResolver().getClassDescriptor(
- ((ObjectId) nodeId).getEntityName());
+ id.getEntityName());
return descriptor.getProperty(propertyName);
}
@@ -138,30 +138,30 @@ class DataContextMergeHandler implements GraphChangeHandler, DataChannelListener
// *** GraphChangeHandler methods
@Override
- public void nodeIdChanged(Object nodeId, Object newId) {
- context.getObjectStore().processIdChange(nodeId, newId);
+ public void nodeIdChanged(ObjectId id, ObjectId newId) {
+ context.getObjectStore().processIdChange(id, newId);
}
@Override
- public void nodeRemoved(Object nodeId) {
+ public void nodeRemoved(ObjectId id) {
DataContextObjectStore os = context.getObjectStore();
synchronized (os) {
- os.processDeletedID((ObjectId) nodeId);
+ os.processDeletedID(id);
}
}
@Override
public void nodePropertyChanged(
- Object nodeId,
+ ObjectId id,
String property,
Object oldValue,
Object newValue) {
- Persistent object = context.getObjectStore().getObject(nodeId);
+ Persistent object = context.getObjectStore().getObject(id);
if (object != null && object.getPersistenceState() != PersistenceState.HOLLOW) {
// do not override local changes....
- PropertyDescriptor p = propertyForId(nodeId, property);
+ PropertyDescriptor p = propertyForId(id, property);
if (p.equals(p.readPropertyDirectly(object), oldValue)) {
p.writePropertyDirectly(object, oldValue, newValue);
}
@@ -169,24 +169,24 @@ class DataContextMergeHandler implements GraphChangeHandler, DataChannelListener
}
@Override
- public void arcCreated(Object nodeId, Object targetNodeId, ArcId arcId) {
- arcChanged(nodeId, arcId);
+ public void arcCreated(ObjectId id, ObjectId targetId, ArcId arcId) {
+ arcChanged(id, arcId);
}
@Override
- public void arcDeleted(Object nodeId, Object targetNodeId, ArcId arcId) {
- arcChanged(nodeId, arcId);
+ public void arcDeleted(ObjectId id, ObjectId targetId, ArcId arcId) {
+ arcChanged(id, arcId);
}
// works the same for add and remove as long as we don't get too smart per TODO below.
- private void arcChanged(Object nodeId, Object arcId) {
+ private void arcChanged(ObjectId id, Object arcId) {
- final Persistent source = context.getObjectStore().getObject(nodeId);
+ final Persistent source = context.getObjectStore().getObject(id);
if (source != null && source.getPersistenceState() != PersistenceState.HOLLOW) {
final int state = source.getPersistenceState();
- PropertyDescriptor p = propertyForId(nodeId, arcId.toString());
+ PropertyDescriptor p = propertyForId(id, arcId.toString());
p.visit(new PropertyVisitor() {
public boolean visitAttribute(AttributeProperty property) {
diff --git a/cayenne/src/main/java/org/apache/cayenne/access/DataContextObjectStore.java b/cayenne/src/main/java/org/apache/cayenne/access/DataContextObjectStore.java
index 0a17b0f3a..ce718b719 100644
--- a/cayenne/src/main/java/org/apache/cayenne/access/DataContextObjectStore.java
+++ b/cayenne/src/main/java/org/apache/cayenne/access/DataContextObjectStore.java
@@ -70,15 +70,16 @@ public class DataContextObjectStore implements ObjectStore, SnapshotEventListene
protected final DataContext context;
protected final DataRowStore dataRowCache;
- protected final Map<Object, Persistent> objectMap;
+ protected final Map<ObjectId, Persistent> objectMap;
- protected Map<Object, ObjectDiff> changes;
+ protected Map<ObjectId, ObjectDiff> changes;
/**
* Presence of path in this map is used to separate insert from update case of flattened records.
*/
- protected Map<Object, Map<CayennePath, ObjectId>> trackedFlattenedPaths;
+ protected Map<ObjectId, Map<CayennePath, ObjectId>> trackedFlattenedPaths;
private Collection<GraphDiff> lifecycleEventInducedChanges;
+ private final ChangeRecorder changeRecorder;
// a sequential id used to tag GraphDiffs so that they can later be sorted in the
// original creation order
@@ -87,16 +88,17 @@ public class DataContextObjectStore implements ObjectStore, SnapshotEventListene
public DataContextObjectStore(
DataContext context,
DataRowStore dataRowCache,
- Map<Object, Persistent> objectMap,
+ Map<ObjectId, Persistent> objectMap,
boolean syncWithSnapshotCache) {
this.context = Objects.requireNonNull(context);
this.dataRowCache = dataRowCache;
+ this.changeRecorder = new ChangeRecorder();
this.objectMap = Objects.requireNonNull(objectMap, "Object map is null.");
- if (objectMap instanceof SoftValueMap<Object, Persistent> softValueMap) {
+ if (objectMap instanceof SoftValueMap<ObjectId, Persistent> softValueMap) {
softValueMap.setKeyCleanupCallback(this::onObjectKeyCleanup);
- } else if (objectMap instanceof WeakValueMap<Object, Persistent> weakValueMap) {
+ } else if (objectMap instanceof WeakValueMap<ObjectId, Persistent> weakValueMap) {
weakValueMap.setKeyCleanupCallback(this::onObjectKeyCleanup);
}
@@ -115,23 +117,14 @@ public class DataContextObjectStore implements ObjectStore, SnapshotEventListene
}
}
- /**
- * @since 3.0
- */
void childContextSyncStarted() {
lifecycleEventInducedChanges = new ArrayList<>();
}
- /**
- * @since 3.0
- */
void childContextSyncStopped() {
lifecycleEventInducedChanges = null;
}
- /**
- * @since 3.0
- */
Collection<GraphDiff> getLifecycleEventInducedChanges() {
return lifecycleEventInducedChanges != null
? lifecycleEventInducedChanges
@@ -149,22 +142,20 @@ public class DataContextObjectStore implements ObjectStore, SnapshotEventListene
/**
* Registers object change.
- *
- * @since 1.2
*/
- synchronized ObjectDiff registerDiff(Object nodeId, NodeDiff diff) {
+ synchronized ObjectDiff registerDiff(ObjectId id, NodeDiff diff) {
if (diff != null) {
diff.setDiffId(++currentDiffId);
}
- ObjectDiff objectDiff = changes.get(nodeId);
+ ObjectDiff objectDiff = changes.get(id);
if (objectDiff == null) {
- Persistent object = objectMap.get(nodeId);
+ Persistent object = objectMap.get(id);
if (object == null) {
- throw new CayenneRuntimeException("No object is registered in context with Id %s", nodeId);
+ throw new CayenneRuntimeException("No object is registered in context with Id %s", id);
}
if (object.getPersistenceState() == PersistenceState.COMMITTED) {
@@ -172,7 +163,7 @@ public class DataContextObjectStore implements ObjectStore, SnapshotEventListene
// TODO: andrus 3/23/2006 snapshot versions are obsolete, but there is no
// replacement yet, so we still need to handle them...
- DataRow snapshot = getCachedSnapshot((ObjectId) nodeId);
+ DataRow snapshot = getCachedSnapshot(id);
if (snapshot != null
&& snapshot.getVersion() != object.getSnapshotVersion()) {
@@ -181,7 +172,7 @@ public class DataContextObjectStore implements ObjectStore, SnapshotEventListene
ClassDescriptor descriptor = context
.getEntityResolver()
.getClassDescriptor(
- ((ObjectId) nodeId).getEntityName());
+ id.getEntityName());
DataRowUtils.forceMergeWithSnapshot(
context,
descriptor,
@@ -195,7 +186,7 @@ public class DataContextObjectStore implements ObjectStore, SnapshotEventListene
objectDiff = new ObjectDiff(object);
objectDiff.setDiffId(++currentDiffId);
- changes.put(nodeId, objectDiff);
+ changes.put(id, objectDiff);
}
if (diff != null) {
@@ -207,8 +198,6 @@ public class DataContextObjectStore implements ObjectStore, SnapshotEventListene
/**
* Returns a number of objects currently registered with this ObjectStore.
- *
- * @since 1.2
*/
public int registeredObjectsCount() {
return objectMap.size();
@@ -224,8 +213,6 @@ public class DataContextObjectStore implements ObjectStore, SnapshotEventListene
/**
* Turns registered objects with the given ids HOLLOW, discarding their uncommitted changes. Ids of unregistered
* or NEW objects are ignored. Does not touch the snapshot cache.
- *
- * @since 5.0
*/
synchronized void objectsInvalidated(Collection<ObjectId> ids) {
for (ObjectId id : ids) {
@@ -286,8 +273,6 @@ public class DataContextObjectStore implements ObjectStore, SnapshotEventListene
/**
* Reverts changes to all stored uncomitted objects.
- *
- * @since 1.1
*/
public synchronized void objectsRolledBack() {
Iterator<Persistent> it = getObjectIterator();
@@ -317,8 +302,6 @@ public class DataContextObjectStore implements ObjectStore, SnapshotEventListene
/**
* Builds and returns GraphDiff reflecting all uncommitted object changes.
- *
- * @since 1.2
*/
ObjectStoreGraphDiff getChanges() {
return new ObjectStoreGraphDiff(this);
@@ -326,19 +309,14 @@ public class DataContextObjectStore implements ObjectStore, SnapshotEventListene
/**
* Returns internal changes map.
- *
- * @since 1.2
*/
- Map<Object, ObjectDiff> getChangesByObjectId() {
+ Map<ObjectId, ObjectDiff> getChangesByObjectId() {
return changes;
}
- /**
- * @since 1.2
- */
void postprocessAfterPhantomCommit() {
- for (Object id : changes.keySet()) {
+ for (ObjectId id : changes.keySet()) {
Persistent object = objectMap.get(id);
@@ -353,13 +331,11 @@ public class DataContextObjectStore implements ObjectStore, SnapshotEventListene
/**
* Internal unsynchronized method to process objects state after commit.
- *
- * @since 1.2
*/
public void postprocessAfterCommit(GraphDiff parentChanges) {
// scan through changed objects, set persistence state to committed
- for (Object id : changes.keySet()) {
+ for (ObjectId id : changes.keySet()) {
Persistent object = objectMap.get(id);
switch (object.getPersistenceState()) {
@@ -380,8 +356,8 @@ public class DataContextObjectStore implements ObjectStore, SnapshotEventListene
if (!parentChanges.isNoop()) {
parentChanges.apply(new GraphChangeHandler() {
@Override
- public void nodeIdChanged(Object nodeId, Object newId) {
- processIdChange(nodeId, newId);
+ public void nodeIdChanged(ObjectId id, ObjectId newId) {
+ processIdChange(id, newId);
}
});
}
@@ -396,8 +372,6 @@ public class DataContextObjectStore implements ObjectStore, SnapshotEventListene
* Snapshots are keyed by the concrete entity of an object, so an id of a superentity is matched against the ids of
* its subentities as well. A nested context has no snapshot cache of its own, so it takes the current state of the
* object in the parent context as the snapshot.
- *
- * @since 1.1
*/
@Override
public DataRow getCachedSnapshot(ObjectId oid) {
@@ -521,8 +495,6 @@ public class DataContextObjectStore implements ObjectStore, SnapshotEventListene
* DataRowStore, since it is normally invoked *AFTER* the DataRowStore was modified as
* a result of some external interaction.
* </p>
- *
- * @since 1.1
*/
@Override
public void snapshotsChanged(SnapshotEvent event) {
@@ -532,9 +504,6 @@ public class DataContextObjectStore implements ObjectStore, SnapshotEventListene
}
}
- /**
- * @since 1.2
- */
synchronized void processSnapshotEvent(SnapshotEvent event) {
Map<ObjectId, DataRow> modifiedDiffs = event.getModifiedDiffs();
@@ -565,21 +534,21 @@ public class DataContextObjectStore implements ObjectStore, SnapshotEventListene
context.fireDataChannelChanged(originatingContext, diff);
}
- void processIdChange(Object nodeId, Object newId) {
- Persistent object = objectMap.remove(nodeId);
+ void processIdChange(ObjectId id, ObjectId newId) {
+ Persistent object = objectMap.remove(id);
if (object != null) {
- object.setObjectId((ObjectId) newId);
+ object.setObjectId(newId);
objectMap.put(newId, object);
- ObjectDiff change = changes.remove(nodeId);
+ ObjectDiff change = changes.remove(id);
if (change != null) {
changes.put(newId, change);
}
}
if (trackedFlattenedPaths != null) {
- Map<CayennePath, ObjectId> paths = trackedFlattenedPaths.remove(nodeId);
+ Map<CayennePath, ObjectId> paths = trackedFlattenedPaths.remove(id);
if (paths != null) {
trackedFlattenedPaths.put(newId, paths);
}
@@ -588,13 +557,11 @@ public class DataContextObjectStore implements ObjectStore, SnapshotEventListene
/**
* Requires external synchronization.
- *
- * @since 1.2
*/
- void processDeletedID(ObjectId nodeId) {
+ void processDeletedID(ObjectId id) {
// access object map directly - the method should be called in a synchronized context...
- Persistent object = objectMap.get(nodeId);
+ Persistent object = objectMap.get(id);
if (object != null) {
DataContextDelegate delegate;
@@ -603,10 +570,10 @@ public class DataContextObjectStore implements ObjectStore, SnapshotEventListene
case PersistenceState.COMMITTED, PersistenceState.HOLLOW, PersistenceState.DELETED -> {
delegate = context.nonNullDelegate();
if (delegate.shouldProcessDelete(object)) {
- objectMap.remove(nodeId);
- changes.remove(nodeId);
+ objectMap.remove(id);
+ changes.remove(id);
if (trackedFlattenedPaths != null) {
- trackedFlattenedPaths.remove(nodeId);
+ trackedFlattenedPaths.remove(id);
}
// setting DataContext to null will also set state to transient
object.setObjectContext(null);
@@ -617,9 +584,9 @@ public class DataContextObjectStore implements ObjectStore, SnapshotEventListene
delegate = context.nonNullDelegate();
if (delegate.shouldProcessDelete(object)) {
object.setPersistenceState(PersistenceState.NEW);
- changes.remove(nodeId);
- registerObject(nodeId, object);
- nodeCreated(nodeId);
+ changes.remove(id);
+ registerObject(id, object);
+ changeRecorder.nodeCreated(id);
delegate.finishedProcessDelete(object);
}
}
@@ -627,13 +594,10 @@ public class DataContextObjectStore implements ObjectStore, SnapshotEventListene
}
}
- /**
- * @since 1.1
- */
void processInvalidatedIDs(Collection<ObjectId> invalidatedIDs) {
if (invalidatedIDs != null && !invalidatedIDs.isEmpty()) {
for (ObjectId oid : invalidatedIDs) {
- Persistent object = (Persistent) getObject(oid);
+ Persistent object = getObject(oid);
if (object == null) {
continue;
@@ -718,10 +682,10 @@ public class DataContextObjectStore implements ObjectStore, SnapshotEventListene
*
* @since 1.1
*/
- void processUpdatedSnapshot(ObjectId nodeId, DataRow diff) {
+ void processUpdatedSnapshot(ObjectId id, DataRow diff) {
// access object map directly - the method should be called in a synchronized context...
- Persistent object = objectMap.get(nodeId);
+ Persistent object = objectMap.get(id);
// no object, or HOLLOW object require no processing
if (object != null) {
@@ -736,7 +700,7 @@ public class DataContextObjectStore implements ObjectStore, SnapshotEventListene
if (delegate.shouldMergeChanges(object, diff)) {
ClassDescriptor descriptor = context
.getEntityResolver()
- .getClassDescriptor(nodeId.getEntityName());
+ .getClassDescriptor(id.getEntityName());
// TODO: andrus, 5/26/2006 - call to 'getSnapshot' is expensive,
// however my attempts to merge the 'diff' instead of snapshot
@@ -763,7 +727,7 @@ public class DataContextObjectStore implements ObjectStore, SnapshotEventListene
if (delegate.shouldMergeChanges(object, diff)) {
ClassDescriptor descriptor = context
.getEntityResolver()
- .getClassDescriptor(nodeId.getEntityName());
+ .getClassDescriptor(id.getEntityName());
DataRowUtils.forceMergeWithSnapshot(
context,
descriptor,
@@ -776,44 +740,24 @@ public class DataContextObjectStore implements ObjectStore, SnapshotEventListene
}
}
- // *********** ObjectStore Methods *********
- // =========================================
-
- /**
- * Returns a registered Persistent objects or null of no object exists for the ObjectId.
- *
- * @since 1.2
- */
@Override
- public synchronized Persistent getObject(Object nodeId) {
- return objectMap.get(nodeId);
+ public synchronized Persistent getObject(ObjectId id) {
+ return objectMap.get(id);
}
- /**
- * Returns all registered Persistent objects. List is returned by copy and can be modified by
- * the caller.
- *
- * @since 1.2
- */
@Override
public synchronized Collection<Persistent> registeredObjects() {
return new ArrayList<>(objectMap.values());
}
- /**
- * @since 1.2
- */
@Override
- public synchronized void registerObject(Object nodeId, Persistent nodeObject) {
- objectMap.put(nodeId, nodeObject);
+ public synchronized void registerObject(ObjectId id, Persistent nodeObject) {
+ objectMap.put(id, nodeObject);
}
- /**
- * @since 1.2
- */
@Override
- public synchronized Persistent unregisterObject(Object nodeId) {
- Persistent object = objectMap.get(nodeId);
+ public synchronized Persistent unregisterObject(ObjectId id) {
+ Persistent object = objectMap.get(id);
if (object != null) {
objectsUnregistered(Collections.singleton(object));
}
@@ -821,99 +765,10 @@ public class DataContextObjectStore implements ObjectStore, SnapshotEventListene
return object;
}
- /**
- * Does nothing.
- *
- * @since 1.2
- */
- @Override
- public void nodeIdChanged(Object nodeId, Object newId) {
- throw new UnsupportedOperationException("nodeIdChanged");
+ GraphChangeHandler changeRecorder() {
+ return changeRecorder;
}
- /**
- * @since 1.2
- */
- @Override
- public void nodeCreated(Object nodeId) {
- NodeDiff diff = new NodeCreateOperation(nodeId);
-
- if (lifecycleEventInducedChanges != null) {
- registerLifecycleEventInducedChange(diff);
- }
-
- registerDiff(nodeId, diff);
- }
-
- /**
- * @since 1.2
- */
- @Override
- public void nodeRemoved(Object nodeId) {
-
- NodeDiff diff = new NodeDeleteOperation(nodeId);
-
- if (lifecycleEventInducedChanges != null) {
- registerLifecycleEventInducedChange(diff);
- }
-
- registerDiff(nodeId, diff);
- }
-
- /**
- * Records dirty object snapshot.
- *
- * @since 1.2
- */
- @Override
- public void nodePropertyChanged(
- Object nodeId,
- String property,
- Object oldValue,
- Object newValue) {
-
- if (lifecycleEventInducedChanges != null) {
- registerLifecycleEventInducedChange(new NodePropertyChangeOperation(
- nodeId,
- property,
- oldValue,
- newValue));
- }
-
- registerDiff(nodeId, null);
- }
-
- /**
- * @since 1.2
- */
- @Override
- public void arcCreated(Object nodeId, Object targetNodeId, ArcId arcId) {
- NodeDiff diff = new ArcOperation(nodeId, targetNodeId, arcId, false);
-
- if (lifecycleEventInducedChanges != null) {
- registerLifecycleEventInducedChange(diff);
- }
-
- registerDiff(nodeId, diff);
- }
-
- /**
- * @since 1.2
- */
- @Override
- public void arcDeleted(Object nodeId, Object targetNodeId, ArcId arcId) {
- NodeDiff diff = new ArcOperation(nodeId, targetNodeId, arcId, true);
-
- if (lifecycleEventInducedChanges != null) {
- registerLifecycleEventInducedChange(diff);
- }
-
- registerDiff(nodeId, diff);
- }
-
- /**
- * @since 4.2
- */
public ObjectId getFlattenedId(ObjectId objectId, CayennePath path) {
if (trackedFlattenedPaths == null) {
return null;
@@ -923,9 +778,6 @@ public class DataContextObjectStore implements ObjectStore, SnapshotEventListene
.getOrDefault(objectId, Collections.emptyMap()).get(path);
}
- /**
- * @since 4.2
- */
public Collection<ObjectId> getFlattenedIds(ObjectId objectId) {
if (trackedFlattenedPaths == null) {
return Collections.emptyList();
@@ -935,9 +787,6 @@ public class DataContextObjectStore implements ObjectStore, SnapshotEventListene
.getOrDefault(objectId, Collections.emptyMap()).values();
}
- /**
- * @since 5.0
- */
public Map<CayennePath, ObjectId> getFlattenedPathIdMap(ObjectId objectId) {
if (trackedFlattenedPaths == null) {
return Collections.emptyMap();
@@ -998,4 +847,67 @@ public class DataContextObjectStore implements ObjectStore, SnapshotEventListene
throw new UnsupportedOperationException();
}
}
+
+ /**
+ * Records object graph changes as uncommitted diffs.
+ */
+ private class ChangeRecorder implements GraphChangeHandler {
+
+ @Override
+ public void nodeCreated(ObjectId id) {
+ NodeDiff diff = new NodeCreateOperation(id);
+
+ if (lifecycleEventInducedChanges != null) {
+ registerLifecycleEventInducedChange(diff);
+ }
+
+ registerDiff(id, diff);
+ }
+
+ @Override
+ public void nodeRemoved(ObjectId id) {
+ NodeDiff diff = new NodeDeleteOperation(id);
+
+ if (lifecycleEventInducedChanges != null) {
+ registerLifecycleEventInducedChange(diff);
+ }
+
+ registerDiff(id, diff);
+ }
+
+ /**
+ * Records dirty object snapshot.
+ */
+ @Override
+ public void nodePropertyChanged(ObjectId id, String property, Object oldValue, Object newValue) {
+ if (lifecycleEventInducedChanges != null) {
+ registerLifecycleEventInducedChange(
+ new NodePropertyChangeOperation(id, property, oldValue, newValue));
+ }
+
+ registerDiff(id, null);
+ }
+
+ @Override
+ public void arcCreated(ObjectId id, ObjectId targetId, ArcId arcId) {
+ NodeDiff diff = new ArcOperation(id, targetId, arcId, false);
+
+ if (lifecycleEventInducedChanges != null) {
+ registerLifecycleEventInducedChange(diff);
+ }
+
+ registerDiff(id, diff);
+ }
+
+ @Override
+ public void arcDeleted(ObjectId id, ObjectId targetId, ArcId arcId) {
+ NodeDiff diff = new ArcOperation(id, targetId, arcId, true);
+
+ if (lifecycleEventInducedChanges != null) {
+ registerLifecycleEventInducedChange(diff);
+ }
+
+ registerDiff(id, diff);
+ }
+ }
}
diff --git a/cayenne/src/main/java/org/apache/cayenne/access/DefaultObjectMapRetainStrategy.java b/cayenne/src/main/java/org/apache/cayenne/access/DefaultObjectMapRetainStrategy.java
index 05f248ed8..40d0d9efb 100644
--- a/cayenne/src/main/java/org/apache/cayenne/access/DefaultObjectMapRetainStrategy.java
+++ b/cayenne/src/main/java/org/apache/cayenne/access/DefaultObjectMapRetainStrategy.java
@@ -18,6 +18,7 @@
****************************************************************/
package org.apache.cayenne.access;
+import org.apache.cayenne.ObjectId;
import java.util.HashMap;
import java.util.Map;
@@ -46,7 +47,7 @@ public class DefaultObjectMapRetainStrategy implements ObjectMapRetainStrategy {
this.runtimeProperties = runtimeProperties;
}
- public Map<Object, Persistent> createObjectMap() {
+ public Map<ObjectId, Persistent> createObjectMap() {
String strategy = runtimeProperties.get(Constants.OBJECT_RETAIN_STRATEGY_PROPERTY);
if (strategy == null || WEAK_RETAIN_STRATEGY.equals(strategy)) {
diff --git a/cayenne/src/main/java/org/apache/cayenne/access/ObjectDiff.java b/cayenne/src/main/java/org/apache/cayenne/access/ObjectDiff.java
index e24e1524e..ff2fff74a 100644
--- a/cayenne/src/main/java/org/apache/cayenne/access/ObjectDiff.java
+++ b/cayenne/src/main/java/org/apache/cayenne/access/ObjectDiff.java
@@ -181,7 +181,7 @@ public class ObjectDiff extends NodeDiff {
collection.addAll(otherDiffs);
}
- collection.add(new NodeDiff(nodeId, diffId) {
+ collection.add(new NodeDiff(id, diffId) {
@Override
public void apply(GraphChangeHandler tracker) {
@@ -200,7 +200,7 @@ public class ObjectDiff extends NodeDiff {
boolean addDiff = true;
if (diff instanceof ArcOperation arcDiff) {
- Object targetId = arcDiff.getTargetNodeId();
+ ObjectId targetId = arcDiff.getTargetNodeId();
ArcId arcId = arcDiff.getArcId();
ArcProperty property = (ArcProperty) getClassDescriptor().getProperty(arcId.getForwardArc());
@@ -408,7 +408,7 @@ public class ObjectDiff extends NodeDiff {
if (snapshot == null) {
if (newValue != null) {
- handler.nodePropertyChanged(nodeId, property.getName(), null, newValue);
+ handler.nodePropertyChanged(id, property.getName(), null, newValue);
}
}
// have baseline to compare
@@ -416,7 +416,7 @@ public class ObjectDiff extends NodeDiff {
Object oldValue = snapshot.get(property.getName());
if (!property.equals(oldValue, newValue)) {
- handler.nodePropertyChanged(nodeId, property.getName(), oldValue, newValue);
+ handler.nodePropertyChanged(id, property.getName(), oldValue, newValue);
}
}
@@ -448,14 +448,14 @@ public class ObjectDiff extends NodeDiff {
static final class ArcOperation extends NodeDiff {
- private final Object targetNodeId;
+ private final ObjectId targetId;
private final ArcId arcId;
private final boolean delete;
- ArcOperation(Object nodeId, Object targetNodeId, ArcId arcId, boolean delete) {
+ ArcOperation(ObjectId id, ObjectId targetId, ArcId arcId, boolean delete) {
- super(nodeId);
- this.targetNodeId = targetNodeId;
+ super(id);
+ this.targetId = targetId;
this.arcId = arcId;
this.delete = delete;
}
@@ -467,7 +467,7 @@ public class ObjectDiff extends NodeDiff {
@Override
public int hashCode() {
// assuming String and ObjectId provide a good hashCode
- return 31 * arcId.hashCode() + targetNodeId.hashCode();
+ return 31 * arcId.hashCode() + targetId.hashCode();
}
@Override
@@ -484,16 +484,16 @@ public class ObjectDiff extends NodeDiff {
if (!(object instanceof ArcOperation other)) {
return false;
}
- return arcId.equals(other.arcId) && Objects.equals(targetNodeId, other.targetNodeId);
+ return arcId.equals(other.arcId) && Objects.equals(targetId, other.targetId);
}
@Override
public void apply(GraphChangeHandler tracker) {
if (delete) {
- tracker.arcDeleted(nodeId, targetNodeId, arcId);
+ tracker.arcDeleted(id, targetId, arcId);
} else {
- tracker.arcCreated(nodeId, targetNodeId, arcId);
+ tracker.arcCreated(id, targetId, arcId);
}
}
@@ -506,8 +506,8 @@ public class ObjectDiff extends NodeDiff {
return arcId;
}
- public Object getTargetNodeId() {
- return targetNodeId;
+ public ObjectId getTargetNodeId() {
+ return targetId;
}
}
}
diff --git a/cayenne/src/main/java/org/apache/cayenne/access/ObjectMapRetainStrategy.java b/cayenne/src/main/java/org/apache/cayenne/access/ObjectMapRetainStrategy.java
index 9876bdbf4..96a91502b 100644
--- a/cayenne/src/main/java/org/apache/cayenne/access/ObjectMapRetainStrategy.java
+++ b/cayenne/src/main/java/org/apache/cayenne/access/ObjectMapRetainStrategy.java
@@ -18,6 +18,7 @@
****************************************************************/
package org.apache.cayenne.access;
+import org.apache.cayenne.ObjectId;
import java.util.Map;
import org.apache.cayenne.Persistent;
@@ -30,5 +31,5 @@ import org.apache.cayenne.Persistent;
*/
public interface ObjectMapRetainStrategy {
- Map<Object, Persistent> createObjectMap();
+ Map<ObjectId, Persistent> createObjectMap();
}
diff --git a/cayenne/src/main/java/org/apache/cayenne/access/ObjectStoreGraphDiff.java b/cayenne/src/main/java/org/apache/cayenne/access/ObjectStoreGraphDiff.java
index 40547dfdf..ebf91ef8b 100644
--- a/cayenne/src/main/java/org/apache/cayenne/access/ObjectStoreGraphDiff.java
+++ b/cayenne/src/main/java/org/apache/cayenne/access/ObjectStoreGraphDiff.java
@@ -55,7 +55,7 @@ public class ObjectStoreGraphDiff implements GraphDiff {
preprocess(objectStore);
}
- public Map<Object, ObjectDiff> getChangesByObjectId() {
+ public Map<ObjectId, ObjectDiff> getChangesByObjectId() {
return objectStore.getChangesByObjectId();
}
@@ -155,7 +155,7 @@ public class ObjectStoreGraphDiff implements GraphDiff {
if (resolvedDiff == null || lastSeenDiffId < objectStore.currentDiffId) {
CompoundDiff diff = new CompoundDiff();
- Map<Object, ObjectDiff> changes = getChangesByObjectId();
+ Map<ObjectId, ObjectDiff> changes = getChangesByObjectId();
if (!changes.isEmpty()) {
List<NodeDiff> allChanges = new ArrayList<>(changes.size() * 2);
@@ -176,12 +176,12 @@ public class ObjectStoreGraphDiff implements GraphDiff {
private void preprocess(DataContextObjectStore objectStore) {
- Map<Object, ObjectDiff> changes = getChangesByObjectId();
+ Map<ObjectId, ObjectDiff> changes = getChangesByObjectId();
if (!changes.isEmpty()) {
- for (Entry<Object, ObjectDiff> entry : changes.entrySet()) {
+ for (Entry<ObjectId, ObjectDiff> entry : changes.entrySet()) {
- ObjectId id = (ObjectId) entry.getKey();
+ ObjectId id = entry.getKey();
Persistent object = objectStore.getObject(id);
diff --git a/cayenne/src/main/java/org/apache/cayenne/access/PrefetchProcessorNode.java b/cayenne/src/main/java/org/apache/cayenne/access/PrefetchProcessorNode.java
index 0833ae040..4b72b531d 100644
--- a/cayenne/src/main/java/org/apache/cayenne/access/PrefetchProcessorNode.java
+++ b/cayenne/src/main/java/org/apache/cayenne/access/PrefetchProcessorNode.java
@@ -19,6 +19,7 @@
package org.apache.cayenne.access;
+import org.apache.cayenne.ObjectId;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -258,14 +259,14 @@ class PrefetchProcessorNode extends PrefetchTreeNode {
}
@Override
- public void arcCreated(Object nodeId, Object targetNodeId, ArcId arcId) {
+ public void arcCreated(ObjectId id, ObjectId targetId, ArcId arcId) {
if(arcId.getForwardArc().equals(property.getName())) {
hasArcDiff = true;
}
}
@Override
- public void arcDeleted(Object nodeId, Object targetNodeId, ArcId arcId) {
+ public void arcDeleted(ObjectId id, ObjectId targetId, ArcId arcId) {
if(arcId.getForwardArc().equals(property.getName())) {
hasArcDiff = true;
}
diff --git a/cayenne/src/main/java/org/apache/cayenne/access/flush/ArcValuesCreationHandler.java b/cayenne/src/main/java/org/apache/cayenne/access/flush/ArcValuesCreationHandler.java
index c529f791c..2867313f4 100644
--- a/cayenne/src/main/java/org/apache/cayenne/access/flush/ArcValuesCreationHandler.java
+++ b/cayenne/src/main/java/org/apache/cayenne/access/flush/ArcValuesCreationHandler.java
@@ -57,21 +57,21 @@ class ArcValuesCreationHandler implements GraphChangeHandler {
this.defaultType = defaultType;
}
- public void arcCreated(Object nodeId, Object targetNodeId, ArcId arcId) {
- processArcChange(nodeId, targetNodeId, arcId, true);
+ public void arcCreated(ObjectId id, ObjectId targetId, ArcId arcId) {
+ processArcChange(id, targetId, arcId, true);
}
- public void arcDeleted(Object nodeId, Object targetNodeId, ArcId arcId) {
- processArcChange(nodeId, targetNodeId, arcId, false);
+ public void arcDeleted(ObjectId id, ObjectId targetId, ArcId arcId) {
+ processArcChange(id, targetId, arcId, false);
}
- private void processArcChange(Object nodeId, Object targetNodeId, ArcId arcId, boolean created) {
- ObjectId actualTargetId = (ObjectId)targetNodeId;
+ private void processArcChange(ObjectId id, ObjectId targetId, ArcId arcId, boolean created) {
+ ObjectId actualTargetId = (ObjectId)targetId;
ObjectId snapshotId = factory.getDiff().getCurrentArcSnapshotValue(arcId.getForwardArc());
if(snapshotId != null) {
actualTargetId = snapshotId;
}
- ArcTarget arcTarget = new ArcTarget((ObjectId) nodeId, actualTargetId, arcId, !created);
+ ArcTarget arcTarget = new ArcTarget(id, actualTargetId, arcId, !created);
if(factory.getProcessedArcs().contains(arcTarget.getReversed())) {
return;
}
diff --git a/cayenne/src/main/java/org/apache/cayenne/access/flush/DataDomainIndirectDiffBuilder.java b/cayenne/src/main/java/org/apache/cayenne/access/flush/DataDomainIndirectDiffBuilder.java
index 1b6f56b6e..d32fde022 100644
--- a/cayenne/src/main/java/org/apache/cayenne/access/flush/DataDomainIndirectDiffBuilder.java
+++ b/cayenne/src/main/java/org/apache/cayenne/access/flush/DataDomainIndirectDiffBuilder.java
@@ -57,26 +57,26 @@ final class DataDomainIndirectDiffBuilder implements GraphChangeHandler {
}
@Override
- public void arcCreated(Object nodeId, Object targetNodeId, ArcId arcId) {
- processArcChange((ObjectId) nodeId, arcId);
+ public void arcCreated(ObjectId id, ObjectId targetId, ArcId arcId) {
+ processArcChange(id, arcId);
}
@Override
- public void arcDeleted(Object nodeId, Object targetNodeId, ArcId arcId) {
- processArcChange((ObjectId) nodeId, arcId);
+ public void arcDeleted(ObjectId id, ObjectId targetId, ArcId arcId) {
+ processArcChange(id, arcId);
}
- private void processArcChange(ObjectId nodeId, ArcId arcId) {
- ObjEntity entity = resolver.getObjEntity(nodeId.getEntityName());
+ private void processArcChange(ObjectId id, ArcId arcId) {
+ ObjEntity entity = resolver.getObjEntity(id.getEntityName());
ObjRelationship relationship = entity.getRelationship(arcId.getForwardArc());
if (relationship != null && relationship.isSourceIndependentFromTargetChange()) {
// do not record temporary id mods...
- if (!nodeId.isTemporary()) {
+ if (!id.isTemporary()) {
if(indirectModifications == null) {
indirectModifications = new HashSet<>();
}
- indirectModifications.add(nodeId);
+ indirectModifications.add(id);
}
if (relationship.isFlattened() && relationship.isReadOnly()) {
diff --git a/cayenne/src/main/java/org/apache/cayenne/access/flush/DbRowOpFactory.java b/cayenne/src/main/java/org/apache/cayenne/access/flush/DbRowOpFactory.java
index 7fa45bce8..d6250ad2a 100644
--- a/cayenne/src/main/java/org/apache/cayenne/access/flush/DbRowOpFactory.java
+++ b/cayenne/src/main/java/org/apache/cayenne/access/flush/DbRowOpFactory.java
@@ -19,11 +19,10 @@
package org.apache.cayenne.access.flush;
-import org.apache.cayenne.CayenneRuntimeException;
import org.apache.cayenne.ObjectId;
import org.apache.cayenne.Persistent;
-import org.apache.cayenne.access.ObjectDiff;
import org.apache.cayenne.access.DataContextObjectStore;
+import org.apache.cayenne.access.ObjectDiff;
import org.apache.cayenne.access.flush.operation.DbRowOp;
import org.apache.cayenne.access.flush.operation.DbRowOpType;
import org.apache.cayenne.access.flush.operation.DeleteDbRowOpFactory;
@@ -71,7 +70,7 @@ class DbRowOpFactory {
}
private void updateDiff(ObjectDiff diff) {
- ObjectId id = (ObjectId) diff.getNodeId();
+ ObjectId id = diff.getNodeId();
this.diff = diff;
this.descriptor = resolver.getClassDescriptor(id.getEntityName());
this.object = store.getObject(id);
@@ -102,15 +101,11 @@ class DbRowOpFactory {
if (store.getObject(id) == null && !id.getEntityName().startsWith("db:")) {
return null;
}
- switch (type) {
- case INSERT:
- return new InsertDbRowOp(object, entity, id);
- case UPDATE:
- return new UpdateDbRowOp(object, entity, id);
- case DELETE:
- return deleteDbRowOpFactory.createOp(object, entity, id);
- }
- throw new CayenneRuntimeException("Unknown DbRowType '%s'", type);
+ return switch (type) {
+ case INSERT -> new InsertDbRowOp(object, entity, id);
+ case UPDATE -> new UpdateDbRowOp(object, entity, id);
+ case DELETE -> deleteDbRowOpFactory.createOp(object, entity, id);
+ };
}
ClassDescriptor getDescriptor() {
diff --git a/cayenne/src/main/java/org/apache/cayenne/access/flush/DefaultDataDomainFlushAction.java b/cayenne/src/main/java/org/apache/cayenne/access/flush/DefaultDataDomainFlushAction.java
index 6901dee74..7e0f9dfa7 100644
--- a/cayenne/src/main/java/org/apache/cayenne/access/flush/DefaultDataDomainFlushAction.java
+++ b/cayenne/src/main/java/org/apache/cayenne/access/flush/DefaultDataDomainFlushAction.java
@@ -107,7 +107,7 @@ public class DefaultDataDomainFlushAction implements DataDomainFlushAction {
protected List<DbRowOp> createDbRowOps(DataContextObjectStore objectStore, ObjectStoreGraphDiff changes) {
EntityResolver resolver = dataDomain.getEntityResolver();
- Map<Object, ObjectDiff> changesByObjectId = changes.getChangesByObjectId();
+ Map<ObjectId, ObjectDiff> changesByObjectId = changes.getChangesByObjectId();
List<DbRowOp> ops = new ArrayList<>(changesByObjectId.size());
Set<ArcTarget> processedArcs = new HashSet<>();
diff --git a/cayenne/src/main/java/org/apache/cayenne/access/flush/ValuesCreationHandler.java b/cayenne/src/main/java/org/apache/cayenne/access/flush/ValuesCreationHandler.java
index 5b498a30f..c1b0a5acd 100644
--- a/cayenne/src/main/java/org/apache/cayenne/access/flush/ValuesCreationHandler.java
+++ b/cayenne/src/main/java/org/apache/cayenne/access/flush/ValuesCreationHandler.java
@@ -40,8 +40,7 @@ class ValuesCreationHandler extends ArcValuesCreationHandler {
}
@Override
- public void nodePropertyChanged(Object nodeId, String property, Object oldValue, Object newValue) {
- ObjectId id = (ObjectId)nodeId;
+ public void nodePropertyChanged(ObjectId id, String property, Object oldValue, Object newValue) {
ObjEntity entity = factory.getDescriptor().getEntity();
if(entity.isReadOnly()) {
throw new CayenneRuntimeException("Attempt to modify object(s) mapped to a read-only entity: '%s'. " +
@@ -62,7 +61,7 @@ class ValuesCreationHandler extends ArcValuesCreationHandler {
if(id == null) {
// some extra safety, shouldn't happen
throw new CayenneRuntimeException("Unable to resolve DB row PK for object's %s update of property '%s'"
- , nodeId, property);
+ , id, property);
}
DbAttribute dbAttribute = attribute.getDbAttribute();
diff --git a/cayenne/src/main/java/org/apache/cayenne/commitlog/DeletedDiffProcessor.java b/cayenne/src/main/java/org/apache/cayenne/commitlog/DeletedDiffProcessor.java
index 36d28388c..a74a9d3f3 100644
--- a/cayenne/src/main/java/org/apache/cayenne/commitlog/DeletedDiffProcessor.java
+++ b/cayenne/src/main/java/org/apache/cayenne/commitlog/DeletedDiffProcessor.java
@@ -48,8 +48,7 @@ class DeletedDiffProcessor implements GraphChangeHandler {
}
@Override
- public void nodeRemoved(Object nodeId) {
- ObjectId id = (ObjectId) nodeId;
+ public void nodeRemoved(ObjectId id) {
final MutableObjectChange objectChangeSet = changeSet.getOrCreate(id, ObjectChangeType.DELETE);
diff --git a/cayenne/src/main/java/org/apache/cayenne/commitlog/DiffFilter.java b/cayenne/src/main/java/org/apache/cayenne/commitlog/DiffFilter.java
index b69c7d02c..9d3329635 100644
--- a/cayenne/src/main/java/org/apache/cayenne/commitlog/DiffFilter.java
+++ b/cayenne/src/main/java/org/apache/cayenne/commitlog/DiffFilter.java
@@ -39,29 +39,29 @@ class DiffFilter implements GraphChangeHandler {
}
@Override
- public void nodeIdChanged(Object nodeId, Object newId) {
- if (entityFactory.getEntity((ObjectId) nodeId).isIncluded()) {
- delegate.nodeIdChanged(nodeId, newId);
+ public void nodeIdChanged(ObjectId id, ObjectId newId) {
+ if (entityFactory.getEntity(id).isIncluded()) {
+ delegate.nodeIdChanged(id, newId);
}
}
@Override
- public void nodeCreated(Object nodeId) {
- if (entityFactory.getEntity((ObjectId) nodeId).isIncluded()) {
- delegate.nodeCreated(nodeId);
+ public void nodeCreated(ObjectId id) {
+ if (entityFactory.getEntity(id).isIncluded()) {
+ delegate.nodeCreated(id);
}
}
@Override
- public void nodeRemoved(Object nodeId) {
- if (entityFactory.getEntity((ObjectId) nodeId).isIncluded()) {
- delegate.nodeRemoved(nodeId);
+ public void nodeRemoved(ObjectId id) {
+ if (entityFactory.getEntity(id).isIncluded()) {
+ delegate.nodeRemoved(id);
}
}
@Override
- public void nodePropertyChanged(Object nodeId, String property, Object oldValue, Object newValue) {
- CommitLogEntity entity = entityFactory.getEntity((ObjectId) nodeId);
+ public void nodePropertyChanged(ObjectId id, String property, Object oldValue, Object newValue) {
+ CommitLogEntity entity = entityFactory.getEntity(id);
if (entity.isIncluded(property)) {
if (entity.isConfidential(property)) {
@@ -69,21 +69,21 @@ class DiffFilter implements GraphChangeHandler {
newValue = Confidential.getInstance();
}
- delegate.nodePropertyChanged(nodeId, property, oldValue, newValue);
+ delegate.nodePropertyChanged(id, property, oldValue, newValue);
}
}
@Override
- public void arcCreated(Object nodeId, Object targetNodeId, ArcId arcId) {
- if (entityFactory.getEntity((ObjectId) nodeId).isIncluded(arcId.toString())) {
- delegate.arcCreated(nodeId, targetNodeId, arcId);
+ public void arcCreated(ObjectId id, ObjectId targetId, ArcId arcId) {
+ if (entityFactory.getEntity(id).isIncluded(arcId.toString())) {
+ delegate.arcCreated(id, targetId, arcId);
}
}
@Override
- public void arcDeleted(Object nodeId, Object targetNodeId, ArcId arcId) {
- if (entityFactory.getEntity((ObjectId) nodeId).isIncluded(arcId.toString())) {
- delegate.arcDeleted(nodeId, targetNodeId, arcId);
+ public void arcDeleted(ObjectId id, ObjectId targetId, ArcId arcId) {
+ if (entityFactory.getEntity(id).isIncluded(arcId.toString())) {
+ delegate.arcDeleted(id, targetId, arcId);
}
}
}
diff --git a/cayenne/src/main/java/org/apache/cayenne/commitlog/DiffProcessor.java b/cayenne/src/main/java/org/apache/cayenne/commitlog/DiffProcessor.java
index b54d59ac5..a0d3f6d95 100644
--- a/cayenne/src/main/java/org/apache/cayenne/commitlog/DiffProcessor.java
+++ b/cayenne/src/main/java/org/apache/cayenne/commitlog/DiffProcessor.java
@@ -44,29 +44,28 @@ class DiffProcessor implements GraphChangeHandler {
}
@Override
- public void nodeRemoved(Object nodeId) {
+ public void nodeRemoved(ObjectId id) {
// do nothing... deletes are processed pre-commit
}
@Override
- public void nodePropertyChanged(Object nodeId, String property, Object oldValue, Object newValue) {
- changeSet.getOrCreate((ObjectId) nodeId, ObjectChangeType.UPDATE).attributeChanged(property, oldValue,
+ public void nodePropertyChanged(ObjectId id, String property, Object oldValue, Object newValue) {
+ changeSet.getOrCreate(id, ObjectChangeType.UPDATE).attributeChanged(property, oldValue,
newValue);
}
@Override
- public void nodeIdChanged(Object nodeId, Object newId) {
- changeSet.aliasId((ObjectId) nodeId, (ObjectId) newId);
+ public void nodeIdChanged(ObjectId id, ObjectId newId) {
+ changeSet.aliasId(id, newId);
}
@Override
- public void nodeCreated(Object nodeId) {
- changeSet.getOrCreate((ObjectId) nodeId, ObjectChangeType.INSERT);
+ public void nodeCreated(ObjectId id) {
+ changeSet.getOrCreate(id, ObjectChangeType.INSERT);
}
@Override
- public void arcDeleted(Object nodeId, Object targetNodeId, ArcId arcId) {
- ObjectId id = (ObjectId) nodeId;
+ public void arcDeleted(ObjectId id, ObjectId targetId, ArcId arcId) {
String relationshipName = arcId.toString();
ObjEntity entity = entityResolver.getObjEntity(id.getEntityName());
@@ -74,19 +73,16 @@ class DiffProcessor implements GraphChangeHandler {
MutableObjectChange c = changeSet.getOrCreate(id, ObjectChangeType.UPDATE);
- ObjectId tid = (ObjectId) targetNodeId;
-
if (relationship.isToMany()) {
- c.toManyRelationshipDisconnected(relationshipName, tid);
+ c.toManyRelationshipDisconnected(relationshipName, targetId);
} else {
- c.toOneRelationshipDisconnected(relationshipName, tid);
+ c.toOneRelationshipDisconnected(relationshipName, targetId);
}
}
@Override
- public void arcCreated(Object nodeId, Object targetNodeId, ArcId arcId) {
+ public void arcCreated(ObjectId id, ObjectId targetId, ArcId arcId) {
- ObjectId id = (ObjectId) nodeId;
String relationshipName = arcId.toString();
ObjEntity entity = entityResolver.getObjEntity(id.getEntityName());
@@ -94,12 +90,10 @@ class DiffProcessor implements GraphChangeHandler {
MutableObjectChange c = changeSet.getOrCreate(id, ObjectChangeType.UPDATE);
- ObjectId tid = (ObjectId) targetNodeId;
-
if (relationship.isToMany()) {
- c.toManyRelationshipConnected(relationshipName, tid);
+ c.toManyRelationshipConnected(relationshipName, targetId);
} else {
- c.toOneRelationshipConnected(relationshipName, tid);
+ c.toOneRelationshipConnected(relationshipName, targetId);
}
}
}
diff --git a/cayenne/src/main/java/org/apache/cayenne/configuration/runtime/DataContextFactory.java b/cayenne/src/main/java/org/apache/cayenne/configuration/runtime/DataContextFactory.java
index 752f89921..1454a9bab 100644
--- a/cayenne/src/main/java/org/apache/cayenne/configuration/runtime/DataContextFactory.java
+++ b/cayenne/src/main/java/org/apache/cayenne/configuration/runtime/DataContextFactory.java
@@ -18,6 +18,7 @@
****************************************************************/
package org.apache.cayenne.configuration.runtime;
+import org.apache.cayenne.ObjectId;
import org.apache.cayenne.DataChannel;
import org.apache.cayenne.ObjectContext;
import org.apache.cayenne.access.DataContext;
diff --git a/cayenne/src/main/java/org/apache/cayenne/graph/ArcCreateOperation.java b/cayenne/src/main/java/org/apache/cayenne/graph/ArcCreateOperation.java
index 15428441a..91fd36c43 100644
--- a/cayenne/src/main/java/org/apache/cayenne/graph/ArcCreateOperation.java
+++ b/cayenne/src/main/java/org/apache/cayenne/graph/ArcCreateOperation.java
@@ -19,41 +19,42 @@
package org.apache.cayenne.graph;
+import org.apache.cayenne.ObjectId;
/**
* @since 1.2
*/
public class ArcCreateOperation extends NodeDiff {
- protected Object targetNodeId;
+ protected ObjectId targetId;
protected ArcId arcId;
- public ArcCreateOperation(Object nodeId, Object targetNodeId, ArcId arcId) {
- super(nodeId);
- this.targetNodeId = targetNodeId;
+ public ArcCreateOperation(ObjectId id, ObjectId targetId, ArcId arcId) {
+ super(id);
+ this.targetId = targetId;
this.arcId = arcId;
}
- public ArcCreateOperation(Object nodeId, Object targetNodeId, ArcId arcId, int diffId) {
- super(nodeId, diffId);
- this.targetNodeId = targetNodeId;
+ public ArcCreateOperation(ObjectId id, ObjectId targetId, ArcId arcId, int diffId) {
+ super(id, diffId);
+ this.targetId = targetId;
this.arcId = arcId;
}
@Override
public void apply(GraphChangeHandler tracker) {
- tracker.arcCreated(nodeId, targetNodeId, arcId);
+ tracker.arcCreated(id, targetId, arcId);
}
@Override
public void undo(GraphChangeHandler tracker) {
- tracker.arcDeleted(nodeId, targetNodeId, arcId);
+ tracker.arcDeleted(id, targetId, arcId);
}
public Object getArcId() {
return arcId;
}
- public Object getTargetNodeId() {
- return targetNodeId;
+ public ObjectId getTargetNodeId() {
+ return targetId;
}
}
diff --git a/cayenne/src/main/java/org/apache/cayenne/graph/ArcDeleteOperation.java b/cayenne/src/main/java/org/apache/cayenne/graph/ArcDeleteOperation.java
index 148b5ab53..6f2f2c01e 100644
--- a/cayenne/src/main/java/org/apache/cayenne/graph/ArcDeleteOperation.java
+++ b/cayenne/src/main/java/org/apache/cayenne/graph/ArcDeleteOperation.java
@@ -19,41 +19,42 @@
package org.apache.cayenne.graph;
+import org.apache.cayenne.ObjectId;
/**
* @since 1.2
*/
public class ArcDeleteOperation extends NodeDiff {
- protected Object targetNodeId;
+ protected ObjectId targetId;
protected ArcId arcId;
- public ArcDeleteOperation(Object nodeId, Object targetNodeId, ArcId arcId) {
- super(nodeId);
- this.targetNodeId = targetNodeId;
+ public ArcDeleteOperation(ObjectId id, ObjectId targetId, ArcId arcId) {
+ super(id);
+ this.targetId = targetId;
this.arcId = arcId;
}
- public ArcDeleteOperation(Object nodeId, Object targetNodeId, ArcId arcId, int diffId) {
- super(nodeId, diffId);
- this.targetNodeId = targetNodeId;
+ public ArcDeleteOperation(ObjectId id, ObjectId targetId, ArcId arcId, int diffId) {
+ super(id, diffId);
+ this.targetId = targetId;
this.arcId = arcId;
}
@Override
public void apply(GraphChangeHandler tracker) {
- tracker.arcDeleted(nodeId, targetNodeId, arcId);
+ tracker.arcDeleted(id, targetId, arcId);
}
@Override
public void undo(GraphChangeHandler tracker) {
- tracker.arcCreated(nodeId, targetNodeId, arcId);
+ tracker.arcCreated(id, targetId, arcId);
}
public Object getArcId() {
return arcId;
}
- public Object getTargetNodeId() {
- return targetNodeId;
+ public ObjectId getTargetNodeId() {
+ return targetId;
}
}
diff --git a/cayenne/src/main/java/org/apache/cayenne/graph/ChildDiffLoader.java b/cayenne/src/main/java/org/apache/cayenne/graph/ChildDiffLoader.java
index 639b5f719..76f0ab094 100644
--- a/cayenne/src/main/java/org/apache/cayenne/graph/ChildDiffLoader.java
+++ b/cayenne/src/main/java/org/apache/cayenne/graph/ChildDiffLoader.java
@@ -70,17 +70,16 @@ public class ChildDiffLoader implements GraphChangeHandler {
}
@Override
- public void nodeIdChanged(Object nodeId, Object newId) {
+ public void nodeIdChanged(ObjectId id, ObjectId newId) {
throw new CayenneRuntimeException("Not supported");
}
@Override
- public void nodeCreated(Object nodeId) {
+ public void nodeCreated(ObjectId id) {
setExternalChange(Boolean.TRUE);
try {
- ObjectId id = (ObjectId) nodeId;
if (id.getEntityName() == null) {
throw new NullPointerException("Null entity name in id " + id);
}
@@ -95,9 +94,9 @@ public class ChildDiffLoader implements GraphChangeHandler {
}
@Override
- public void nodeRemoved(Object nodeId) {
+ public void nodeRemoved(ObjectId id) {
setExternalChange(Boolean.TRUE);
- Persistent object = findObject(nodeId);
+ Persistent object = findObject(id);
if (object != null) {
try {
context.deleteObjects(object);
@@ -110,14 +109,14 @@ public class ChildDiffLoader implements GraphChangeHandler {
}
@Override
- public void nodePropertyChanged(Object nodeId, String property, Object oldValue, Object newValue) {
+ public void nodePropertyChanged(ObjectId id, String property, Object oldValue, Object newValue) {
// this change is for simple property, so no need to convert targets to
// server
// objects...
- Persistent object = findObject(nodeId);
+ Persistent object = findObject(id);
ClassDescriptor descriptor = context.getEntityResolver()
- .getClassDescriptor(((ObjectId) nodeId).getEntityName());
+ .getClassDescriptor(id.getEntityName());
setExternalChange(Boolean.TRUE);
try {
@@ -130,10 +129,10 @@ public class ChildDiffLoader implements GraphChangeHandler {
}
@Override
- public void arcCreated(Object nodeId, Object targetNodeId, ArcId arcId) {
+ public void arcCreated(ObjectId id, ObjectId targetId, ArcId arcId) {
- final Persistent source = findObject(nodeId);
- final Persistent target = findObject(targetNodeId);
+ final Persistent source = findObject(id);
+ final Persistent target = findObject(targetId);
// if a target was later deleted, the diff for arcCreated is still
// preserved and
@@ -143,7 +142,7 @@ public class ChildDiffLoader implements GraphChangeHandler {
}
ClassDescriptor descriptor = context.getEntityResolver()
- .getClassDescriptor(((ObjectId) nodeId).getEntityName());
+ .getClassDescriptor(id.getEntityName());
ArcProperty property = (ArcProperty) descriptor.getProperty(arcId.toString());
setExternalChange(Boolean.TRUE);
@@ -175,8 +174,8 @@ public class ChildDiffLoader implements GraphChangeHandler {
}
@Override
- public void arcDeleted(Object nodeId, final Object targetNodeId, ArcId arcId) {
- final Persistent source = findObject(nodeId);
+ public void arcDeleted(ObjectId id, final ObjectId targetId, ArcId arcId) {
+ final Persistent source = findObject(id);
// needed as sometime temporary objects are evoked from the context
// before
@@ -186,7 +185,7 @@ public class ChildDiffLoader implements GraphChangeHandler {
}
ClassDescriptor descriptor = context.getEntityResolver()
- .getClassDescriptor(((ObjectId) nodeId).getEntityName());
+ .getClassDescriptor(id.getEntityName());
PropertyDescriptor property = descriptor.getProperty(arcId.toString());
setExternalChange(Boolean.TRUE);
@@ -203,7 +202,7 @@ public class ChildDiffLoader implements GraphChangeHandler {
ArcProperty reverseArc = property.getComplimentaryReverseArc();
boolean autoConnectReverse = reverseArc != null && reverseArc.getRelationship().isRuntime();
- Persistent target = findObject(targetNodeId);
+ Persistent target = findObject(targetId);
if (target == null) {
@@ -216,7 +215,7 @@ public class ChildDiffLoader implements GraphChangeHandler {
// collection ...
// the performance of this is rather dubious of
// course...
- target = findObjectInCollection(targetNodeId, property.readProperty(source));
+ target = findObjectInCollection(targetId, property.readProperty(source));
}
if (target == null) {
@@ -238,17 +237,16 @@ public class ChildDiffLoader implements GraphChangeHandler {
}
}
- protected Persistent findObject(Object nodeId) {
+ protected Persistent findObject(ObjectId id) {
// first do a lookup in ObjectStore; if even a hollow object is found,
// return it;
// if not - fetch.
- Persistent object = context.getObjectStore().getObject(nodeId);
+ Persistent object = context.getObjectStore().getObject(id);
if (object != null) {
return object;
}
- ObjectId id = (ObjectId) nodeId;
// this can happen if a NEW object is deleted and after that its
// relationships are
@@ -260,18 +258,18 @@ public class ChildDiffLoader implements GraphChangeHandler {
// skip context cache lookup, go directly to its channel
object = context.getChannel().onIdQuery(context, id);
if (object == null) {
- throw new CayenneRuntimeException("No object for ID exists: %s", nodeId);
+ throw new CayenneRuntimeException("No object for ID exists: %s", id);
}
return object;
}
- protected Persistent findObjectInCollection(Object nodeId, Object toManyHolder) {
+ protected Persistent findObjectInCollection(ObjectId id, Object toManyHolder) {
Collection<?> c = (toManyHolder instanceof Map) ? ((Map<?, ?>) toManyHolder).values() : (Collection<?>) toManyHolder;
for(Object o : c) {
Persistent p = (Persistent) o;
- if (nodeId.equals(p.getObjectId())) {
+ if (id.equals(p.getObjectId())) {
return p;
}
}
diff --git a/cayenne/src/main/java/org/apache/cayenne/graph/GraphChangeHandler.java b/cayenne/src/main/java/org/apache/cayenne/graph/GraphChangeHandler.java
index d2651666e..129b41862 100644
--- a/cayenne/src/main/java/org/apache/cayenne/graph/GraphChangeHandler.java
+++ b/cayenne/src/main/java/org/apache/cayenne/graph/GraphChangeHandler.java
@@ -19,6 +19,7 @@
package org.apache.cayenne.graph;
+import org.apache.cayenne.ObjectId;
/**
* Defines callback API that can be used by object graph nodes to notify of their state
* changes. Graph nodes can be any objects as long as each node supports a notion of a
@@ -32,26 +33,26 @@ public interface GraphChangeHandler {
/**
* Notifies implementing object that a node was assigned a new id.
*/
- default void nodeIdChanged(Object nodeId, Object newId) {
+ default void nodeIdChanged(ObjectId id, ObjectId newId) {
}
/**
* Notifies implementing object that a new node was created in the graph.
*/
- default void nodeCreated(Object nodeId) {
+ default void nodeCreated(ObjectId id) {
}
/**
* Notifies implementing object that a node was removed from the graph.
*/
- default void nodeRemoved(Object nodeId) {
+ default void nodeRemoved(ObjectId id) {
}
/**
* Notifies implementing object that a node's property was modified.
*/
default void nodePropertyChanged(
- Object nodeId,
+ ObjectId id,
String property,
Object oldValue,
Object newValue) {
@@ -60,12 +61,12 @@ public interface GraphChangeHandler {
/**
* Notifies implementing object that a new arc was created between two nodes.
*/
- default void arcCreated(Object nodeId, Object targetNodeId, ArcId arcId) {
+ default void arcCreated(ObjectId id, ObjectId targetId, ArcId arcId) {
}
/**
* Notifies implementing object that an arc between two nodes was deleted.
*/
- default void arcDeleted(Object nodeId, Object targetNodeId, ArcId arcId) {
+ default void arcDeleted(ObjectId id, ObjectId targetId, ArcId arcId) {
}
}
diff --git a/cayenne/src/main/java/org/apache/cayenne/graph/GraphDiffCompressor.java b/cayenne/src/main/java/org/apache/cayenne/graph/GraphDiffCompressor.java
index caa2791c9..a8ebf6580 100644
--- a/cayenne/src/main/java/org/apache/cayenne/graph/GraphDiffCompressor.java
+++ b/cayenne/src/main/java/org/apache/cayenne/graph/GraphDiffCompressor.java
@@ -18,6 +18,7 @@
****************************************************************/
package org.apache.cayenne.graph;
+import org.apache.cayenne.ObjectId;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
@@ -48,16 +49,16 @@ public class GraphDiffCompressor {
final class CompressAction implements GraphChangeHandler {
private List<GraphDiff> compressed = new ArrayList<>();
- private Map<Object, List<NodeDiff>> diffsByNode = new HashMap<>();
- private Set<Object> deletedNodes;
- private Set<Object> createdNodes;
+ private Map<ObjectId, List<NodeDiff>> diffsByNode = new HashMap<>();
+ private Set<ObjectId> deletedNodes;
+ private Set<ObjectId> createdNodes;
GraphDiff getCompressedDiff() {
// remove deleted nodes...
if (deletedNodes != null) {
- for (Object nodeId : deletedNodes) {
+ for (ObjectId id : deletedNodes) {
Iterator<GraphDiff> it = compressed.iterator();
@@ -68,10 +69,10 @@ public class GraphDiffCompressor {
// TODO: andrus 2008/02/04 - this doesn't take into account a
// possibility that a deleted node was re-inserted... Although I don't
// see how this could possibly happen with the present Cayenne API.
- if (createdNodes != null && createdNodes.contains(nodeId)) {
+ if (createdNodes != null && createdNodes.contains(id)) {
while (it.hasNext()) {
NodeDiff diff = (NodeDiff) it.next();
- if (nodeId.equals(diff.getNodeId())) {
+ if (id.equals(diff.getNodeId())) {
it.remove();
}
}
@@ -79,7 +80,7 @@ public class GraphDiffCompressor {
else {
while (it.hasNext()) {
NodeDiff diff = (NodeDiff) it.next();
- if (nodeId.equals(diff.getNodeId())) {
+ if (id.equals(diff.getNodeId())) {
if (diff instanceof NodePropertyChangeOperation) {
it.remove();
}
@@ -94,17 +95,17 @@ public class GraphDiffCompressor {
}
@Override
- public void arcCreated(Object nodeId, Object targetNodeId, ArcId arcId) {
+ public void arcCreated(ObjectId id, ObjectId targetId, ArcId arcId) {
- if (targetNodeId != null) {
- List<NodeDiff> diffs = diffsByNode.get(nodeId);
+ if (targetId != null) {
+ List<NodeDiff> diffs = diffsByNode.get(id);
if (diffs != null) {
for (int i = diffs.size() - 1; i >= 0; i--) {
NodeDiff diff = diffs.get(i);
if (diff instanceof ArcDeleteOperation) {
ArcDeleteOperation arcDiff = (ArcDeleteOperation) diff;
if (arcId.equals(arcDiff.getArcId())
- && targetNodeId.equals(arcDiff.targetNodeId)) {
+ && targetId.equals(arcDiff.targetId)) {
diffs.remove(i);
compressed.remove(arcDiff);
return;
@@ -114,21 +115,21 @@ public class GraphDiffCompressor {
}
}
- registerDiff(new ArcCreateOperation(nodeId, targetNodeId, arcId));
+ registerDiff(new ArcCreateOperation(id, targetId, arcId));
}
@Override
- public void arcDeleted(Object nodeId, Object targetNodeId, ArcId arcId) {
+ public void arcDeleted(ObjectId id, ObjectId targetId, ArcId arcId) {
- if (targetNodeId != null) {
- List<NodeDiff> diffs = diffsByNode.get(nodeId);
+ if (targetId != null) {
+ List<NodeDiff> diffs = diffsByNode.get(id);
if (diffs != null) {
for (int i = diffs.size() - 1; i >= 0; i--) {
NodeDiff diff = diffs.get(i);
if (diff instanceof ArcCreateOperation) {
ArcCreateOperation arcDiff = (ArcCreateOperation) diff;
if (arcId.equals(arcDiff.getArcId())
- && targetNodeId.equals(arcDiff.targetNodeId)) {
+ && targetId.equals(arcDiff.targetId)) {
diffs.remove(i);
compressed.remove(arcDiff);
return;
@@ -138,45 +139,45 @@ public class GraphDiffCompressor {
}
}
- registerDiff(new ArcDeleteOperation(nodeId, targetNodeId, arcId));
+ registerDiff(new ArcDeleteOperation(id, targetId, arcId));
}
@Override
- public void nodeCreated(Object nodeId) {
- registerDiff(new NodeCreateOperation(nodeId));
+ public void nodeCreated(ObjectId id) {
+ registerDiff(new NodeCreateOperation(id));
if (createdNodes == null) {
createdNodes = new HashSet<>();
}
- createdNodes.add(nodeId);
+ createdNodes.add(id);
}
@Override
- public void nodeIdChanged(Object nodeId, Object newId) {
- registerDiff(new NodeIdChangeOperation(nodeId, newId));
+ public void nodeIdChanged(ObjectId id, ObjectId newId) {
+ registerDiff(new NodeIdChangeOperation(id, newId));
}
@Override
- public void nodeRemoved(Object nodeId) {
+ public void nodeRemoved(ObjectId id) {
- registerDiff(new NodeDeleteOperation(nodeId));
+ registerDiff(new NodeDeleteOperation(id));
if (deletedNodes == null) {
deletedNodes = new HashSet<>();
}
- deletedNodes.add(nodeId);
+ deletedNodes.add(id);
}
@Override
public void nodePropertyChanged(
- Object nodeId,
+ ObjectId id,
String property,
Object oldValue,
Object newValue) {
- List<NodeDiff> diffs = diffsByNode.get(nodeId);
+ List<NodeDiff> diffs = diffsByNode.get(id);
if (diffs != null) {
for (int i = diffs.size() - 1; i >= 0; i--) {
@@ -192,7 +193,7 @@ public class GraphDiffCompressor {
}
registerDiff(new NodePropertyChangeOperation(
- nodeId,
+ id,
property,
oldValue,
newValue));
diff --git a/cayenne/src/main/java/org/apache/cayenne/graph/NodeCreateOperation.java b/cayenne/src/main/java/org/apache/cayenne/graph/NodeCreateOperation.java
index f02d9e22c..b81df48a0 100644
--- a/cayenne/src/main/java/org/apache/cayenne/graph/NodeCreateOperation.java
+++ b/cayenne/src/main/java/org/apache/cayenne/graph/NodeCreateOperation.java
@@ -19,26 +19,27 @@
package org.apache.cayenne.graph;
+import org.apache.cayenne.ObjectId;
/**
* @since 1.2
*/
public class NodeCreateOperation extends NodeDiff {
- public NodeCreateOperation(Object nodeId) {
- super(nodeId);
+ public NodeCreateOperation(ObjectId id) {
+ super(id);
}
- public NodeCreateOperation(Object nodeId, int diffId) {
- super(nodeId, diffId);
+ public NodeCreateOperation(ObjectId id, int diffId) {
+ super(id, diffId);
}
@Override
public void apply(GraphChangeHandler tracker) {
- tracker.nodeCreated(nodeId);
+ tracker.nodeCreated(id);
}
@Override
public void undo(GraphChangeHandler tracker) {
- tracker.nodeRemoved(nodeId);
+ tracker.nodeRemoved(id);
}
}
diff --git a/cayenne/src/main/java/org/apache/cayenne/graph/NodeDeleteOperation.java b/cayenne/src/main/java/org/apache/cayenne/graph/NodeDeleteOperation.java
index 1f3c66fcd..c452f4eba 100644
--- a/cayenne/src/main/java/org/apache/cayenne/graph/NodeDeleteOperation.java
+++ b/cayenne/src/main/java/org/apache/cayenne/graph/NodeDeleteOperation.java
@@ -19,26 +19,27 @@
package org.apache.cayenne.graph;
+import org.apache.cayenne.ObjectId;
/**
* @since 1.2
*/
public class NodeDeleteOperation extends NodeDiff {
- public NodeDeleteOperation(Object nodeId) {
- super(nodeId);
+ public NodeDeleteOperation(ObjectId id) {
+ super(id);
}
- public NodeDeleteOperation(Object nodeId, int diffId) {
- super(nodeId, diffId);
+ public NodeDeleteOperation(ObjectId id, int diffId) {
+ super(id, diffId);
}
@Override
public void apply(GraphChangeHandler tracker) {
- tracker.nodeRemoved(nodeId);
+ tracker.nodeRemoved(id);
}
@Override
public void undo(GraphChangeHandler tracker) {
- tracker.nodeCreated(nodeId);
+ tracker.nodeCreated(id);
}
}
diff --git a/cayenne/src/main/java/org/apache/cayenne/graph/NodeDiff.java b/cayenne/src/main/java/org/apache/cayenne/graph/NodeDiff.java
index 61befbab1..17b0339aa 100644
--- a/cayenne/src/main/java/org/apache/cayenne/graph/NodeDiff.java
+++ b/cayenne/src/main/java/org/apache/cayenne/graph/NodeDiff.java
@@ -19,6 +19,7 @@
package org.apache.cayenne.graph;
+import org.apache.cayenne.ObjectId;
/**
* An abstract superclass of operations on individual nodes and arcs in a
* digraph.
@@ -28,14 +29,14 @@ package org.apache.cayenne.graph;
public abstract class NodeDiff implements GraphDiff, Comparable<NodeDiff> {
protected int diffId;
- protected Object nodeId;
+ protected ObjectId id;
- public NodeDiff(Object nodeId) {
- this.nodeId = nodeId;
+ public NodeDiff(ObjectId id) {
+ this.id = id;
}
- public NodeDiff(Object nodeId, int diffId) {
- this.nodeId = nodeId;
+ public NodeDiff(ObjectId id, int diffId) {
+ this.id = id;
this.diffId = diffId;
}
@@ -50,8 +51,8 @@ public abstract class NodeDiff implements GraphDiff, Comparable<NodeDiff> {
@Override
public abstract void undo(GraphChangeHandler tracker);
- public Object getNodeId() {
- return nodeId;
+ public ObjectId getNodeId() {
+ return id;
}
/**
diff --git a/cayenne/src/main/java/org/apache/cayenne/graph/NodeIdChangeOperation.java b/cayenne/src/main/java/org/apache/cayenne/graph/NodeIdChangeOperation.java
index caf232d99..cafcf5e39 100644
--- a/cayenne/src/main/java/org/apache/cayenne/graph/NodeIdChangeOperation.java
+++ b/cayenne/src/main/java/org/apache/cayenne/graph/NodeIdChangeOperation.java
@@ -19,6 +19,7 @@
package org.apache.cayenne.graph;
+import org.apache.cayenne.ObjectId;
/**
* A GraphDiff representing a change in node ID.
*
@@ -26,26 +27,26 @@ package org.apache.cayenne.graph;
*/
public class NodeIdChangeOperation extends NodeDiff {
- protected Object newNodeId;
+ protected ObjectId newId;
- public NodeIdChangeOperation(Object nodeId, Object newNodeId) {
- super(nodeId);
+ public NodeIdChangeOperation(ObjectId id, ObjectId newId) {
+ super(id);
- this.newNodeId = newNodeId;
+ this.newId = newId;
}
- public NodeIdChangeOperation(Object nodeId, Object newNodeId, int diffId) {
- super(nodeId, diffId);
- this.newNodeId = newNodeId;
+ public NodeIdChangeOperation(ObjectId id, ObjectId newId, int diffId) {
+ super(id, diffId);
+ this.newId = newId;
}
@Override
public void apply(GraphChangeHandler tracker) {
- tracker.nodeIdChanged(nodeId, newNodeId);
+ tracker.nodeIdChanged(id, newId);
}
@Override
public void undo(GraphChangeHandler tracker) {
- tracker.nodeIdChanged(newNodeId, nodeId);
+ tracker.nodeIdChanged(newId, id);
}
}
diff --git a/cayenne/src/main/java/org/apache/cayenne/graph/NodePropertyChangeOperation.java b/cayenne/src/main/java/org/apache/cayenne/graph/NodePropertyChangeOperation.java
index 55f567908..0ba20f679 100644
--- a/cayenne/src/main/java/org/apache/cayenne/graph/NodePropertyChangeOperation.java
+++ b/cayenne/src/main/java/org/apache/cayenne/graph/NodePropertyChangeOperation.java
@@ -19,6 +19,7 @@
package org.apache.cayenne.graph;
+import org.apache.cayenne.ObjectId;
import java.util.Objects;
/**
@@ -30,16 +31,16 @@ public class NodePropertyChangeOperation extends NodeDiff {
protected Object oldValue;
protected Object newValue;
- public NodePropertyChangeOperation(Object nodeId, String property, Object oldValue, Object newValue) {
+ public NodePropertyChangeOperation(ObjectId id, String property, Object oldValue, Object newValue) {
- super(nodeId);
+ super(id);
this.property = property;
this.oldValue = oldValue;
this.newValue = newValue;
}
- public NodePropertyChangeOperation(Object nodeId, String property, Object oldValue, Object newValue, int diffId) {
- super(nodeId, diffId);
+ public NodePropertyChangeOperation(ObjectId id, String property, Object oldValue, Object newValue, int diffId) {
+ super(id, diffId);
this.property = property;
this.oldValue = oldValue;
@@ -72,11 +73,11 @@ public class NodePropertyChangeOperation extends NodeDiff {
@Override
public void apply(GraphChangeHandler tracker) {
- tracker.nodePropertyChanged(nodeId, property, oldValue, newValue);
+ tracker.nodePropertyChanged(id, property, oldValue, newValue);
}
@Override
public void undo(GraphChangeHandler tracker) {
- tracker.nodePropertyChanged(nodeId, property, newValue, oldValue);
+ tracker.nodePropertyChanged(id, property, newValue, oldValue);
}
}
diff --git a/cayenne/src/main/java/org/apache/cayenne/tx/DataChannelSyncCallbackAction.java b/cayenne/src/main/java/org/apache/cayenne/tx/DataChannelSyncCallbackAction.java
index 8951fdf61..0a7379231 100644
--- a/cayenne/src/main/java/org/apache/cayenne/tx/DataChannelSyncCallbackAction.java
+++ b/cayenne/src/main/java/org/apache/cayenne/tx/DataChannelSyncCallbackAction.java
@@ -18,6 +18,7 @@
****************************************************************/
package org.apache.cayenne.tx;
+import org.apache.cayenne.ObjectId;
import org.apache.cayenne.DataChannel;
import org.apache.cayenne.ObjectStore;
import org.apache.cayenne.graph.ArcId;
@@ -57,7 +58,7 @@ abstract class DataChannelSyncCallbackAction implements GraphChangeHandler {
Collection<Object> persisted;
Collection<Object> removed;
- private Map<Object, Op> seenIds;
+ private Map<ObjectId, Op> seenIds;
private final ObjectStore objectStore;
DataChannelSyncCallbackAction(
@@ -87,11 +88,11 @@ abstract class DataChannelSyncCallbackAction implements GraphChangeHandler {
}
@Override
- public void nodeCreated(Object nodeId) {
- Op op = seenIds.put(nodeId, Op.INSERT);
+ public void nodeCreated(ObjectId id) {
+ Op op = seenIds.put(id, Op.INSERT);
if (op == null) {
- Object node = objectStore.getObject(nodeId);
+ Object node = objectStore.getObject(id);
if (node != null) {
if (persisted == null) {
@@ -104,13 +105,13 @@ abstract class DataChannelSyncCallbackAction implements GraphChangeHandler {
}
@Override
- public void nodeRemoved(Object nodeId) {
- Op op = seenIds.put(nodeId, Op.DELETE);
+ public void nodeRemoved(ObjectId id) {
+ Op op = seenIds.put(id, Op.DELETE);
// the node may have been updated prior to delete
if (op != Op.DELETE) {
- Object node = objectStore.getObject(nodeId);
+ Object node = objectStore.getObject(id);
if (node != null) {
if (removed == null) {
@@ -130,32 +131,32 @@ abstract class DataChannelSyncCallbackAction implements GraphChangeHandler {
}
@Override
- public void arcCreated(Object nodeId, Object targetNodeId, ArcId arcId) {
+ public void arcCreated(ObjectId id, ObjectId targetId, ArcId arcId) {
// TODO: andrus, 9/21/2006 - should we register to-many relationship updates?
- nodeUpdated(nodeId);
+ nodeUpdated(id);
}
@Override
- public void arcDeleted(Object nodeId, Object targetNodeId, ArcId arcId) {
+ public void arcDeleted(ObjectId id, ObjectId targetId, ArcId arcId) {
// TODO: andrus, 9/21/2006 - should we register to-many relationship updates?
- nodeUpdated(nodeId);
+ nodeUpdated(id);
}
@Override
public void nodePropertyChanged(
- Object nodeId,
+ ObjectId id,
String property,
Object oldValue,
Object newValue) {
- nodeUpdated(nodeId);
+ nodeUpdated(id);
}
- private void nodeUpdated(Object nodeId) {
- Op op = seenIds.put(nodeId, Op.UPDATE);
+ private void nodeUpdated(ObjectId id) {
+ Op op = seenIds.put(id, Op.UPDATE);
if (op == null) {
- Object node = objectStore.getObject(nodeId);
+ Object node = objectStore.getObject(id);
if (node != null) {
if (updated == null) {
diff --git a/cayenne/src/test/java/org/apache/cayenne/ObjectContextChangeLogTest.java b/cayenne/src/test/java/org/apache/cayenne/ObjectContextChangeLogTest.java
deleted file mode 100644
index 8cfafe3ff..000000000
--- a/cayenne/src/test/java/org/apache/cayenne/ObjectContextChangeLogTest.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- ****************************************************************/
-
-package org.apache.cayenne;
-
-import org.apache.cayenne.graph.CompoundDiff;
-import org.apache.cayenne.graph.GraphDiff;
-import org.apache.cayenne.graph.NodeCreateOperation;
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-public class ObjectContextChangeLogTest {
-
- @Test
- public void testReset() {
- ObjectContextChangeLog recorder = new ObjectContextChangeLog();
- assertNotNull(recorder.getDiffs());
- assertTrue(recorder.getDiffs().isNoop());
-
- recorder.addOperation(new NodeCreateOperation(new Object()));
- assertNotNull(recorder.getDiffs());
- assertFalse(recorder.getDiffs().isNoop());
-
- recorder.reset();
- assertNotNull(recorder.getDiffs());
- assertTrue(recorder.getDiffs().isNoop());
-
- // now test that a diff stored before "clear" is not affected by 'clear'
- recorder.addOperation(new NodeCreateOperation(new Object()));
- GraphDiff diff = recorder.getDiffs();
- assertFalse(diff.isNoop());
-
- recorder.reset();
- assertFalse(diff.isNoop());
- }
-
- @Test
- public void testGetDiffs() {
- // assert that after returning, the diffs array won't get modified by
- // operation
- // recorder
- ObjectContextChangeLog recorder = new ObjectContextChangeLog();
- recorder.addOperation(new NodeCreateOperation(new Object()));
- CompoundDiff diff = (CompoundDiff) recorder.getDiffs();
- assertEquals(1, diff.getDiffs().size());
-
- recorder.addOperation(new NodeCreateOperation(new Object()));
- assertEquals(1, diff.getDiffs().size());
-
- CompoundDiff diff2 = (CompoundDiff) recorder.getDiffs();
- assertEquals(2, diff2.getDiffs().size());
- }
-
-}
diff --git a/cayenne/src/test/java/org/apache/cayenne/graph/NodeDiffTest.java b/cayenne/src/test/java/org/apache/cayenne/graph/NodeDiffTest.java
index 13260c6c3..e4fbfeade 100644
--- a/cayenne/src/test/java/org/apache/cayenne/graph/NodeDiffTest.java
+++ b/cayenne/src/test/java/org/apache/cayenne/graph/NodeDiffTest.java
@@ -19,6 +19,7 @@
package org.apache.cayenne.graph;
+import org.apache.cayenne.ObjectId;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -28,17 +29,17 @@ public class NodeDiffTest {
@Test
public void getNodeId() {
- Object id = new Object();
+ ObjectId id = ObjectId.of("E");
NodeDiff diff = new ConcreteNodeDiff(id);
assertSame(id, diff.getNodeId());
}
@Test
public void compareTo() {
- NodeDiff d1 = new ConcreteNodeDiff("x", 1);
- NodeDiff d2 = new ConcreteNodeDiff("y", 2);
- NodeDiff d3 = new ConcreteNodeDiff("z", 3);
- NodeDiff d4 = new ConcreteNodeDiff("a", 2);
+ NodeDiff d1 = new ConcreteNodeDiff(ObjectId.of("x"), 1);
+ NodeDiff d2 = new ConcreteNodeDiff(ObjectId.of("y"), 2);
+ NodeDiff d3 = new ConcreteNodeDiff(ObjectId.of("z"), 3);
+ NodeDiff d4 = new ConcreteNodeDiff(ObjectId.of("a"), 2);
assertTrue(d1.compareTo(d2) < 0);
assertTrue(d2.compareTo(d1) > 0);
@@ -50,12 +51,12 @@ public class NodeDiffTest {
@SuppressWarnings("serial")
class ConcreteNodeDiff extends NodeDiff {
- public ConcreteNodeDiff(Object nodeId) {
- super(nodeId);
+ public ConcreteNodeDiff(ObjectId id) {
+ super(id);
}
- public ConcreteNodeDiff(Object nodeId, int diffId) {
- super(nodeId, diffId);
+ public ConcreteNodeDiff(ObjectId id, int diffId) {
+ super(id, diffId);
}
@Override