|
From: <me...@us...> - 2002-10-01 03:15:29
|
Update of /cvsroot/cayenne/cayenne/src/cayenne/java/org/objectstyle/cayenne/access
In directory usw-pr-cvs1:/tmp/cvs-serv2251/src/cayenne/java/org/objectstyle/cayenne/access
Modified Files:
DataContext.java
Log Message:
applied patch 616812 by Craig Miskell
Index: DataContext.java
===================================================================
RCS file: /cvsroot/cayenne/cayenne/src/cayenne/java/org/objectstyle/cayenne/access/DataContext.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- DataContext.java 19 Sep 2002 03:14:23 -0000 1.10
+++ DataContext.java 1 Oct 2002 03:15:26 -0000 1.11
@@ -110,7 +110,8 @@
//Will not be directly serialized - see read/writeObject for details
protected transient QueryEngine parent;
- protected Map registeredMap = Collections.synchronizedMap(new HashMap());
+ //Must be deserialized slightly differently - see read/writeObject
+ protected transient Map registeredMap = Collections.synchronizedMap(new HashMap());
protected Map committedSnapshots = Collections.synchronizedMap(new HashMap());
protected RelationshipDataSource relDataSource = new RelationshipDataSource();
@@ -1183,6 +1184,10 @@
out.writeObject(this.parent);
//Hope that whatever this.parent is, that it is Serializable
}
+
+ //For writing, just write the objects. They will be serialized possibly
+ // as just objectIds... it's up to the object itself. Reading will do magic
+ out.writeObject(registeredMap);
}
private void readObject(ObjectInputStream in)
@@ -1209,6 +1214,20 @@
+ value);
}
+ //CayenneDataObjects have a transient datacontext
+ // because at deserialize time the datacontext may need to be different
+
+ // than the one at serialize time (for programmer defined reasons).
+ // So, when a dataobject is resurrected because it's datacontext was
+ // serialized, it will then set the objects datacontext to the correctone
+ // If deser'd "otherwise", it will not have a datacontext (good)
+
+ this.registeredMap = (Map) in.readObject();
+ Iterator it = registeredMap.values().iterator();
+ while (it.hasNext()) {
+ DataObject obj = (DataObject) it.next();
+ obj.setDataContext(this);
+ }
}
/**
|