Author: tfischer
Date: Sun May 15 12:44:45 2011
New Revision: 1103353
URL: http://svn.apache.org/viewvc?rev=1103353&view=rev
Log:
TORQUE-158: simplify serialization of Criteria
Modified:
db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/Criteria.java
Modified:
db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/Criteria.java
URL:
http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/Criteria.java?rev=1103353&r1=1103352&r2=1103353&view=diff
==============================================================================
---
db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/Criteria.java
(original)
+++
db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/Criteria.java
Sun May 15 12:44:45 2011
@@ -179,7 +179,7 @@ public class Criteria implements Seriali
= new LinkedHashMap<String, String>();
/** Contains all joins. */
- private transient List<Join> joins = new ArrayList<Join>();
+ private List<Join> joins = new ArrayList<Join>();
/** The name of the database. */
private String dbName;
@@ -1813,9 +1813,9 @@ public class Criteria implements Seriali
* Checks whether an object is equal to this Criteria.
* This is the case if the other object is also a Criteria and has
* the same attributes and criterions.
- *
+ *
* @param object the other object to check, can be null.
- *
+ *
* @return true if the object is equal to this Criteria, false otherwise.
*/
@Override
@@ -3042,74 +3042,6 @@ public class Criteria implements Seriali
}
/**
- * Serializes this Criteria.
- *
- * @param s The output stream.
- * @throws IOException if an IO error occurs.
- */
- private void writeObject(ObjectOutputStream s) throws IOException
- {
- s.defaultWriteObject();
-
- // Joins need to be serialized manually.
- ArrayList<List<Object>> serializableJoins = null;
- if (!joins.isEmpty())
- {
- serializableJoins = new ArrayList<List<Object>>(joins.size());
-
- for (Iterator<Join> joinsIter = joins.iterator();
joinsIter.hasNext();)
- {
- Join join = joinsIter.next();
-
- ArrayList<Object> joinContent = new ArrayList<Object>(3);
- joinContent.add(join.getLeftColumn());
- joinContent.add(join.getRightColumn());
- joinContent.add(join.getJoinType());
-
- serializableJoins.add(joinContent);
- }
- }
-
- s.writeObject(serializableJoins);
- }
-
- /**
- * Deserialize a Criteria.
- *
- * @param s The input stream.
- * @throws IOException if an IO error occurs.
- * @throws ClassNotFoundException if the class cannot be located.
- */
- private void readObject(ObjectInputStream s)
- throws IOException, ClassNotFoundException
- {
- s.defaultReadObject();
-
- // Joins need to be deserialized manually.
- this.joins = new ArrayList<Join>(3);
-
- ArrayList<List<Object>> joins
- = (ArrayList<List<Object>>) s.readObject();
- if (joins != null)
- {
- for (int i = 0; i < joins.size(); i++)
- {
- List<Object> joinContent = joins.get(i);
-
- String leftColumn = (String) joinContent.get(0);
- String rightColumn = (String) joinContent.get(1);
- SqlEnum joinType = null;
- Object joinTypeObj = joinContent.get(2);
- if (joinTypeObj != null)
- {
- joinType = (SqlEnum) joinTypeObj;
- }
- addJoin(leftColumn, rightColumn, joinType);
- }
- }
- }
-
- /**
* This is an inner class that describes an object in the criteria.
*/
public final class Criterion implements Serializable
@@ -3646,8 +3578,11 @@ public class Criteria implements Seriali
* The class is immutable. Because the class is also used by
* {@link org.apache.torque.util.BasePeer}, it is visible from the package.
*/
- public static class Join
+ public static class Join implements Serializable
{
+ /** Version id for serializing. */
+ private static final long serialVersionUID = 1L;
+
/** the left column of the join condition */
private String leftColumn = null;
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]