I just committed this fix - figured there's nothing controversial
about it :-)
Andrus
On Aug 11, 2007, at 8:19 PM, Andrus Adamchik wrote:
Hi Kevin,
I was able to reproduce it based on your earlier note that you
turned off caching. No shared cache was the cause of the error, so
instead of refreshing I added a check for NULL cache. Additionally
following your hint that this code is meaningless for new objects
anyways, I added a check for temporary ObjectId. This seems to fix
it for me. I am ready to commit it - let me know what you think?
Andrus
Index: framework/cayenne-jdk1.4-unpublished/src/main/java/org/
apache/cayenne/access/DataDomainQueryAction.java
===================================================================
--- framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/
cayenne/access/DataDomainQueryAction.java (revision 560823)
+++ framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/
cayenne/access/DataDomainQueryAction.java (working copy)
@@ -168,10 +168,10 @@
if (query instanceof ObjectIdQuery) {
ObjectIdQuery oidQuery = (ObjectIdQuery) query;
-
DataRow row = null;
- if (!oidQuery.isFetchMandatory()) {
+ if (cache != null
+ && !oidQuery.isFetchMandatory()) {
row = cache.getCachedSnapshot(oidQuery.getObjectId
());
}
@@ -214,8 +214,11 @@
return !DONE;
}
+ if(cache == null) {
+ return !DONE;
+ }
+
DataRow sourceRow = cache.getCachedSnapshot
(relationshipQuery.getObjectId());
-
if (sourceRow == null) {
return !DONE;
}
Index: framework/cayenne-jdk1.4-unpublished/src/main/java/org/
apache/cayenne/map/AshwoodEntitySorter.java
===================================================================
--- framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/
cayenne/map/AshwoodEntitySorter.java (revision 560823)
+++ framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/
cayenne/map/AshwoodEntitySorter.java (working copy)
@@ -302,16 +302,22 @@
// find committed snapshot - so we can't fetch from the
context as it will return
// dirty snapshot; must go down the stack instead
+
+ // how do we handle this for NEW objects correctly? For
now bail from the method
+ if (object.getObjectId().isTemporary()) {
+ return null;
+ }
+
ObjectIdQuery query = new ObjectIdQuery(
object.getObjectId(),
true,
ObjectIdQuery.CACHE);
QueryResponse response = context.getChannel().onQuery
(null, query);
List result = response.firstList();
- if(result == null || result.size() == 0) {
+ if (result == null || result.size() == 0) {
return null;
}
-
+
DataRow snapshot = (DataRow) result.get(0);
ObjectId id = snapshot.createTargetObjectId
(targetEntityName, finalRel);
On Aug 9, 2007, at 6:17 PM, Kevin Menard wrote:
On Aug 9, 2007, at 3:02 AM, Andrus Adamchik wrote:
Kevin,
If you don't mind waiting a few more days, let me play with it
during the weekend. A test case would help.
Andrus
That's fine. I patched my local version as a "works for me"
solution, but didn't want to commit it until I was sure it was
correct. I'll try to get together the test case.
--
Kevin