I am planning to apply the change below to EntityResolver. What it
means internally is that EntityResolver
will become more "pessimistic" and won't attempt to reconstruct the
cache if an entity lookup fails.
What it means to the users is that an exception will be thrown if an
attempt is made to lookup unmapped entity.
Does anyone think that making EntityResolver more tight is a bad
thing (or will disturb too much of the existing code)?
Andrus
Index: EntityResolver.java
===================================================================
RCS file: /cvsroot/cayenne/cayenne/src/cayenne/java/org/objectstyle/
cayenne/map/EntityResolver.java,v
retrieving revision 1.17
diff -u -r1.17 EntityResolver.java
--- EntityResolver.java 30 Sep 2005 03:34:12 -0000 1.17
+++ EntityResolver.java 30 Sep 2005 04:06:38 -0000
..-105,6 +105,8 @@
protected List maps;
protected Map entityInheritanceCache;
protected EntityResolver clientEntityResolver;
+
+ boolean indexed;
/**
* Creates new EntityResolver.
..-286,6 +288,7 @@
procedureCache.clear();
entityInheritanceCache.clear();
clientEntityResolver = null;
+ indexed = false;
}
/**
..-410,6 +413,8 @@
}
}
}
+
+ indexed = true;
}
/**
..-708,12 +713,19 @@
}
ObjEntity result = (ObjEntity) objEntityCache.get(object);
- if (result == null) {
- // reconstruct cache just in case some of the datamaps
- // have changed and now contain the required information
+ if (result != null) {
+ return result;
+ }
+
+ if (!indexed) {
constructCache();
result = (ObjEntity) objEntityCache.get(object);
+
+ if (result != null) {
+ return result;
+ }
}
- return result;
+
+ throw new CayenneRuntimeException("No ObjEntity mapped for
object: " + object);
}
}
This archive was generated by hypermail 2.0.0 : Fri Sep 30 2005 - 00:10:40 EDT