aclute 2005/04/28 13:31:57
Modified: src/java/org/apache/ojb/broker/core Tag: OJB_1_0_RELEASE
PersistenceBrokerImpl.java
Log:
[JIRA]OJB-35 -- Create new getPlainDBObject that does only the DB call, and
now caching or reference retrieval. Alllows for retrieveReference to use it
without stomping on it's cached instance
Revision Changes Path
No revision
No revision
1.83.2.20 +34 -16
db-ojb/src/java/org/apache/ojb/broker/core/PersistenceBrokerImpl.java
Index: PersistenceBrokerImpl.java
===================================================================
RCS file:
/home/cvs/db-ojb/src/java/org/apache/ojb/broker/core/PersistenceBrokerImpl.java,v
retrieving revision 1.83.2.19
retrieving revision 1.83.2.20
diff -u -r1.83.2.19 -r1.83.2.20
--- PersistenceBrokerImpl.java 27 Apr 2005 00:23:52 -0000
1.83.2.19
+++ PersistenceBrokerImpl.java 28 Apr 2005 20:31:56 -0000
1.83.2.20
@@ -1409,23 +1409,16 @@
}
/**
- * Retrieve an object by it's identity from the database
+ * Retrieve an plain object (without populated references) by it's
identity
+ * from the database
*
- * @param oid
- * @return
+ * @param cld the real [EMAIL PROTECTED]
org.apache.ojb.broker.metadata.ClassDescriptor} of the object to refresh
+ * @param oid the [EMAIL PROTECTED] org.apache.ojb.broker.Identity} of
the object
+ * @return A new plain object read from the database or <em>null</em> if
not found
* @throws ClassNotPersistenceCapableException
*/
- private Object getDBObject(Identity oid) throws
ClassNotPersistenceCapableException
+ private Object getPlainDBObject(ClassDescriptor cld, Identity oid)
throws ClassNotPersistenceCapableException
{
- Class c = oid.getObjectsRealClass();
-
- if (c == null)
- {
- logger.info("Real class for used Identity object is 'null', use
top-level class instead");
- c = oid.getObjectsTopLevelClass();
- }
-
- ClassDescriptor cld = getClassDescriptor(c);
Object newObj = null;
// Class is NOT an Interface: it has a directly mapped table and we
lookup this table first:
@@ -1452,6 +1445,31 @@
}
}
}
+ return newObj;
+ }
+
+
+ /**
+ * Retrieve an full materialized (dependent on the metadata settings)
+ * object by it's identity from the database, as well as caching the
+ * object
+ *
+ * @param oid The [EMAIL PROTECTED] org.apache.ojb.broker.Identity} of
the object to for
+ * @return A new object read from the database or <em>null</em> if not
found
+ * @throws ClassNotPersistenceCapableException
+ */
+ private Object getDBObject(Identity oid) throws
ClassNotPersistenceCapableException
+ {
+ Class c = oid.getObjectsRealClass();
+
+ if (c == null)
+ {
+ logger.info("Real class for used Identity object is 'null', use
top-level class instead");
+ c = oid.getObjectsTopLevelClass();
+ }
+
+ ClassDescriptor cld = getClassDescriptor(c);
+ Object newObj = getPlainDBObject(cld, oid);
// loading references is useful only when the Object could be found
in db:
if (newObj != null)
@@ -1608,8 +1626,8 @@
*/
private void refreshInstance(Object cachedInstance, Identity oid,
ClassDescriptor cld)
{
- // read in fresh copy from the db
- Object freshInstance = getDBObject(oid);
+ // read in fresh copy from the db, but do not cache it
+ Object freshInstance = getPlainDBObject(cld, oid);
// update all primitive typed attributes
FieldDescriptor[] fields = cld.getFieldDescriptions();
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]