cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject [3/7] cayenne git commit: Refactoring SelectTranslator for better extensibility
Date Tue, 28 Apr 2015 10:45:08 GMT
http://git-wip-us.apache.org/repos/asf/cayenne/blob/81f4fb50/cayenne-server/src/main/java/org/apache/cayenne/dba/oracle/Oracle8SelectTranslator.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/dba/oracle/Oracle8SelectTranslator.java b/cayenne-server/src/main/java/org/apache/cayenne/dba/oracle/Oracle8SelectTranslator.java
index aa35ada..6d1b16f 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/dba/oracle/Oracle8SelectTranslator.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/dba/oracle/Oracle8SelectTranslator.java
@@ -18,10 +18,9 @@
  ****************************************************************/
 package org.apache.cayenne.dba.oracle;
 
-import java.sql.Connection;
-
-import org.apache.cayenne.access.DataNode;
 import org.apache.cayenne.access.translator.select.JoinStack;
+import org.apache.cayenne.dba.DbAdapter;
+import org.apache.cayenne.map.EntityResolver;
 import org.apache.cayenne.query.Query;
 
 /**
@@ -29,20 +28,20 @@ import org.apache.cayenne.query.Query;
  */
 class Oracle8SelectTranslator extends OracleSelectTranslator {
 
-    /**
-     * @since 4.0
-     */
-    public Oracle8SelectTranslator(Query query, DataNode dataNode, Connection connection) {
-        super(query, dataNode, connection);
-    }
-    
-    /**
-     * Returns an old style joint stack for Oracle8 that does not support explicit join
-     * syntax.
-     */
-    @Override
-    protected JoinStack createJoinStack() {
-        return new Oracle8JoinStack(getAdapter(), queryMetadata.getDataMap(), this);
-    }
+	/**
+	 * @since 4.0
+	 */
+	public Oracle8SelectTranslator(Query query, DbAdapter adapter, EntityResolver entityResolver) {
+		super(query, adapter, entityResolver);
+	}
+
+	/**
+	 * Returns an old style joint stack for Oracle8 that does not support
+	 * explicit join syntax.
+	 */
+	@Override
+	protected JoinStack createJoinStack() {
+		return new Oracle8JoinStack(getAdapter(), queryMetadata.getDataMap(), this);
+	}
 
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/81f4fb50/cayenne-server/src/main/java/org/apache/cayenne/dba/oracle/OracleQualifierTranslator.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/dba/oracle/OracleQualifierTranslator.java b/cayenne-server/src/main/java/org/apache/cayenne/dba/oracle/OracleQualifierTranslator.java
index b375e3f..1ace92e 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/dba/oracle/OracleQualifierTranslator.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/dba/oracle/OracleQualifierTranslator.java
@@ -18,7 +18,6 @@
  ****************************************************************/
 package org.apache.cayenne.dba.oracle;
 
-import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -33,68 +32,65 @@ import org.apache.cayenne.exp.parser.ASTPath;
 import org.apache.commons.collections.Transformer;
 
 /**
- * Oracle qualifier translator. In particular, trims INs with more than 1000 elements to
- * an OR-set of INs with <= 1000 elements
+ * Oracle qualifier translator. In particular, trims INs with more than 1000
+ * elements to an OR-set of INs with <= 1000 elements
  */
 public class OracleQualifierTranslator extends TrimmingQualifierTranslator {
 
-    public OracleQualifierTranslator(QueryAssembler queryAssembler) {
-        super(queryAssembler, OracleAdapter.TRIM_FUNCTION);
-    }
+	public OracleQualifierTranslator(QueryAssembler queryAssembler) {
+		super(queryAssembler, OracleAdapter.TRIM_FUNCTION);
+	}
 
-    @Override
-    protected void doAppendPart(Expression rootNode) throws IOException {
-        if (rootNode == null) {
-            return;
-        }
-        rootNode = rootNode.transform(new INTrimmer());
-        rootNode.traverse(this);
-    }
+	@Override
+	protected void doAppendPart(Expression rootNode) {
+		if (rootNode == null) {
+			return;
+		}
+		rootNode = rootNode.transform(new INTrimmer());
+		rootNode.traverse(this);
+	}
 
-    public static class INTrimmer implements Transformer {
+	public static class INTrimmer implements Transformer {
 
-        public Expression trimmedInExpression(Expression exp, int maxInSize) {
-            Expression list = (Expression) exp.getOperand(1);
-            Object[] objects = (Object[]) list.evaluate(null);
+		public Expression trimmedInExpression(Expression exp, int maxInSize) {
+			Expression list = (Expression) exp.getOperand(1);
+			Object[] objects = (Object[]) list.evaluate(null);
 
-            if (objects.length <= maxInSize) {
-                return exp;
-            }
+			if (objects.length <= maxInSize) {
+				return exp;
+			}
 
-            Expression trimmed = trimmedInExpression(
-                    (ASTPath) exp.getOperand(0),
-                    objects,
-                    maxInSize);
-            if (exp instanceof ASTNotIn) {
-                return new ASTNegate(trimmed);
-            }
-            return trimmed;
-        }
+			Expression trimmed = trimmedInExpression((ASTPath) exp.getOperand(0), objects, maxInSize);
+			if (exp instanceof ASTNotIn) {
+				return new ASTNegate(trimmed);
+			}
+			return trimmed;
+		}
 
-        Expression trimmedInExpression(ASTPath path, Object[] values, int maxInSize) {
-            Expression res = null;
+		Expression trimmedInExpression(ASTPath path, Object[] values, int maxInSize) {
+			Expression res = null;
 
-            List<Object> in = new ArrayList<Object>(maxInSize);
-            for (Object v : values) {
-                in.add(v);
-                if (in.size() == maxInSize) {
-                    Expression inExp = new ASTIn(path, new ASTList(in));
-                    res = res != null ? res.orExp(inExp) : inExp;
-                    in = new ArrayList<Object>(maxInSize);
-                }
-            }
-            if (in.size() > 0) {
-                Expression inExp = new ASTIn(path, new ASTList(in));
-                res = res != null ? res.orExp(inExp) : inExp;
-            }
-            return res;
-        }
+			List<Object> in = new ArrayList<Object>(maxInSize);
+			for (Object v : values) {
+				in.add(v);
+				if (in.size() == maxInSize) {
+					Expression inExp = new ASTIn(path, new ASTList(in));
+					res = res != null ? res.orExp(inExp) : inExp;
+					in = new ArrayList<Object>(maxInSize);
+				}
+			}
+			if (in.size() > 0) {
+				Expression inExp = new ASTIn(path, new ASTList(in));
+				res = res != null ? res.orExp(inExp) : inExp;
+			}
+			return res;
+		}
 
-        public Object transform(Object input) {
-            if (input instanceof ASTIn || input instanceof ASTNotIn) {
-                return trimmedInExpression((Expression) input, 1000);
-            }
-            return input;
-        }
-    }
+		public Object transform(Object input) {
+			if (input instanceof ASTIn || input instanceof ASTNotIn) {
+				return trimmedInExpression((Expression) input, 1000);
+			}
+			return input;
+		}
+	}
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/81f4fb50/cayenne-server/src/main/java/org/apache/cayenne/dba/oracle/OracleSelectAction.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/dba/oracle/OracleSelectAction.java b/cayenne-server/src/main/java/org/apache/cayenne/dba/oracle/OracleSelectAction.java
index de145f3..f361aa4 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/dba/oracle/OracleSelectAction.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/dba/oracle/OracleSelectAction.java
@@ -19,8 +19,6 @@
 
 package org.apache.cayenne.dba.oracle;
 
-import java.sql.Connection;
-
 import org.apache.cayenne.access.DataNode;
 import org.apache.cayenne.access.jdbc.SelectAction;
 import org.apache.cayenne.access.translator.select.SelectTranslator;
@@ -31,17 +29,17 @@ import org.apache.cayenne.query.SelectQuery;
  */
 class OracleSelectAction extends SelectAction {
 
-    public <T> OracleSelectAction(SelectQuery<T> query, DataNode dataNode) {
-        super(query, dataNode);
-    }
+	public <T> OracleSelectAction(SelectQuery<T> query, DataNode dataNode) {
+		super(query, dataNode);
+	}
 
-    @Override
-    protected SelectTranslator createTranslator(Connection connection) {
-        return new OracleSelectTranslator(query, dataNode, connection);
-    }
+	@Override
+	protected SelectTranslator createTranslator() {
+		return new OracleSelectTranslator(query, dataNode.getAdapter(), dataNode.getEntityResolver());
+	}
 
-    @Override
-    protected int getInMemoryOffset(int queryOffset) {
-        return 0;
-    }
+	@Override
+	protected int getInMemoryOffset(int queryOffset) {
+		return 0;
+	}
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/81f4fb50/cayenne-server/src/main/java/org/apache/cayenne/dba/oracle/OracleSelectTranslator.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/dba/oracle/OracleSelectTranslator.java b/cayenne-server/src/main/java/org/apache/cayenne/dba/oracle/OracleSelectTranslator.java
index 911a2c2..fa6e95b 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/dba/oracle/OracleSelectTranslator.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/dba/oracle/OracleSelectTranslator.java
@@ -19,75 +19,54 @@
 
 package org.apache.cayenne.dba.oracle;
 
-import java.sql.Connection;
-import java.sql.PreparedStatement;
 import java.util.List;
 
 import org.apache.cayenne.access.DataNode;
-import org.apache.cayenne.access.translator.select.SelectTranslator;
+import org.apache.cayenne.access.translator.select.DefaultSelectTranslator;
+import org.apache.cayenne.dba.DbAdapter;
+import org.apache.cayenne.map.EntityResolver;
 import org.apache.cayenne.query.Query;
 
 /**
  * Select translator that implements Oracle-specific optimizations.
  * 
  */
-class OracleSelectTranslator extends SelectTranslator {
-    
-    /**
-     * @since 4.0
-     */
-    public OracleSelectTranslator(Query query, DataNode dataNode, Connection connection) {
-        super(query, dataNode, connection);
-    }
+class OracleSelectTranslator extends DefaultSelectTranslator {
 
-    @Override
-    protected void appendLimitAndOffsetClauses(StringBuilder buffer) {
-        int offset = queryMetadata.getFetchOffset();
-        int limit = queryMetadata.getFetchLimit();
+	/**
+	 * @since 4.0
+	 */
+	public OracleSelectTranslator(Query query, DbAdapter adapter, EntityResolver entityResolver) {
+		super(query, adapter, entityResolver);
+	}
 
-        if (limit > 0 || offset > 0) {
-            int max = (limit <= 0) ? Integer.MAX_VALUE : limit + offset;
+	@Override
+	protected void appendLimitAndOffsetClauses(StringBuilder buffer) {
+		int offset = queryMetadata.getFetchOffset();
+		int limit = queryMetadata.getFetchLimit();
 
-            buffer.insert(0, "select * from ( select tid.*, ROWNUM rnum from (");
-            buffer
-                    .append(") tid where ROWNUM <=")
-                    .append(max)
-                    .append(") where rnum  > ")
-                    .append(offset);
-        }
-    }
-    
-    @Override
-    protected void appendSelectColumns(StringBuilder buffer, List<String> selectColumnExpList) {
-        
-        // we need to add aliases to all columns to make fetch
-        // limit and offset work properly on Oracle (see CAY-1266)
-        
-        // append columns (unroll the loop's first element)
-        int columnCount = selectColumnExpList.size();
-        buffer.append(selectColumnExpList.get(0)).append(" AS c0");
+		if (limit > 0 || offset > 0) {
+			int max = (limit <= 0) ? Integer.MAX_VALUE : limit + offset;
 
-        // assume there is at least 1 element
-        for (int i = 1; i < columnCount; i++) {
-            buffer.append(", ");
-            buffer
-                    .append(selectColumnExpList.get(i))
-                    .append(" AS c" + i);
-        }
-    }
+			buffer.insert(0, "select * from ( select tid.*, ROWNUM rnum from (");
+			buffer.append(") tid where ROWNUM <=").append(max).append(") where rnum  > ").append(offset);
+		}
+	}
 
-    /**
-     * Translates internal query into PreparedStatement, applying Oracle optimizations if
-     * possible.
-     */
-    @Override
-    public PreparedStatement createStatement() throws Exception {
-        String sqlStr = createSqlString();
-        logger.logQuery(sqlStr, values);
-        PreparedStatement stmt = connection.prepareStatement(sqlStr);
+	@Override
+	protected void appendSelectColumns(StringBuilder buffer, List<String> selectColumnExpList) {
 
-        initStatement(stmt);
+		// we need to add aliases to all columns to make fetch
+		// limit and offset work properly on Oracle (see CAY-1266)
 
-        return stmt;
-    }
+		// append columns (unroll the loop's first element)
+		int columnCount = selectColumnExpList.size();
+		buffer.append(selectColumnExpList.get(0)).append(" AS c0");
+
+		// assume there is at least 1 element
+		for (int i = 1; i < columnCount; i++) {
+			buffer.append(", ");
+			buffer.append(selectColumnExpList.get(i)).append(" AS c" + i);
+		}
+	}
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/81f4fb50/cayenne-server/src/main/java/org/apache/cayenne/dba/postgres/PostgresQualifierTranslator.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/dba/postgres/PostgresQualifierTranslator.java b/cayenne-server/src/main/java/org/apache/cayenne/dba/postgres/PostgresQualifierTranslator.java
index 3904805..8b8e731 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/dba/postgres/PostgresQualifierTranslator.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/dba/postgres/PostgresQualifierTranslator.java
@@ -34,102 +34,94 @@ import org.apache.cayenne.exp.parser.PatternMatchNode;
  */
 public class PostgresQualifierTranslator extends TrimmingQualifierTranslator {
 
-    public PostgresQualifierTranslator(QueryAssembler queryAssembler) {
-        super(queryAssembler, "RTRIM");
-    }
-
-    @Override
-    public void startNode(Expression node, Expression parentNode) {
-
-        if (node.getOperandCount() == 2) {
-            // binary nodes are the only ones that currently require this
-            detectObjectMatch(node);
-
-            try {
-                if (parenthesisNeeded(node, parentNode)) {
-                    out.append('(');
-                }
-
-                // super implementation has special handling
-                // of LIKE_IGNORE_CASE and NOT_LIKE_IGNORE_CASE
-                // Postgres uses ILIKE
-                // ...
-            }
-            catch (IOException ioex) {
-                throw new CayenneRuntimeException("Error appending content", ioex);
-            }
-        }
-        else {
-            super.startNode(node, parentNode);
-        }
-    }
-
-    @Override
-    public void endNode(Expression node, Expression parentNode) {
-        if (node.getOperandCount() == 2) {
-
-            try {
-                // check if we need to use objectMatchTranslator to finish building the
-                // expression
-                if (matchingObject) {
-                    appendObjectMatch();
-                }
-                
-                if(PatternMatchNode.class.isAssignableFrom(node.getClass())) {
-                    appendLikeEscapeCharacter((PatternMatchNode) node);
-                }
-
-                if (parenthesisNeeded(node, parentNode)) {
-                    out.append(')');
-                }
-
-                // super implementation has special handling
-                // of LIKE_IGNORE_CASE and NOT_LIKE_IGNORE_CASE
-                // Postgres uses ILIKE
-                // ...
-            }
-            catch (IOException ioex) {
-                throw new CayenneRuntimeException("Error appending content", ioex);
-            }
-        }
-        else {
-            super.endNode(node, parentNode);
-        }
-    }
-
-    @Override
-    public void finishedChild(Expression node, int childIndex, boolean hasMoreChildren) {
-        if (!hasMoreChildren) {
-            return;
-        }
-
-        try {
-            // use ILIKE
-
-            switch (node.getType()) {
-
-                case Expression.LIKE_IGNORE_CASE:
-                    finishedChildNodeAppendExpression(node, " ILIKE ");
-                    break;
-                case Expression.NOT_LIKE_IGNORE_CASE:
-                    finishedChildNodeAppendExpression(node, " NOT ILIKE ");
-                    break;
-                default:
-                    super.finishedChild(node, childIndex, hasMoreChildren);
-            }
-        }
-        catch (IOException ioex) {
-            throw new CayenneRuntimeException("Error appending content", ioex);
-        }
-    }
-
-    private void finishedChildNodeAppendExpression(Expression node, String operation)
-            throws IOException {
-        Appendable buf = matchingObject ? new StringBuilder() : this.out;
-        buf.append(operation);
-        if (matchingObject) {
-            objectMatchTranslator.setOperation(buf.toString());
-            objectMatchTranslator.setExpression(node);
-        }
-    }
+	public PostgresQualifierTranslator(QueryAssembler queryAssembler) {
+		super(queryAssembler, "RTRIM");
+	}
+
+	@Override
+	public void startNode(Expression node, Expression parentNode) {
+
+		if (node.getOperandCount() == 2) {
+			// binary nodes are the only ones that currently require this
+			detectObjectMatch(node);
+
+			if (parenthesisNeeded(node, parentNode)) {
+				out.append('(');
+			}
+
+			// super implementation has special handling
+			// of LIKE_IGNORE_CASE and NOT_LIKE_IGNORE_CASE
+			// Postgres uses ILIKE
+			// ...
+
+		} else {
+			super.startNode(node, parentNode);
+		}
+	}
+
+	@Override
+	public void endNode(Expression node, Expression parentNode) {
+		if (node.getOperandCount() == 2) {
+
+			try {
+				// check if we need to use objectMatchTranslator to finish
+				// building the
+				// expression
+				if (matchingObject) {
+					appendObjectMatch();
+				}
+
+				if (PatternMatchNode.class.isAssignableFrom(node.getClass())) {
+					appendLikeEscapeCharacter((PatternMatchNode) node);
+				}
+
+				if (parenthesisNeeded(node, parentNode)) {
+					out.append(')');
+				}
+
+				// super implementation has special handling
+				// of LIKE_IGNORE_CASE and NOT_LIKE_IGNORE_CASE
+				// Postgres uses ILIKE
+				// ...
+			} catch (IOException ioex) {
+				throw new CayenneRuntimeException("Error appending content", ioex);
+			}
+		} else {
+			super.endNode(node, parentNode);
+		}
+	}
+
+	@Override
+	public void finishedChild(Expression node, int childIndex, boolean hasMoreChildren) {
+		if (!hasMoreChildren) {
+			return;
+		}
+
+		try {
+			// use ILIKE
+
+			switch (node.getType()) {
+
+			case Expression.LIKE_IGNORE_CASE:
+				finishedChildNodeAppendExpression(node, " ILIKE ");
+				break;
+			case Expression.NOT_LIKE_IGNORE_CASE:
+				finishedChildNodeAppendExpression(node, " NOT ILIKE ");
+				break;
+			default:
+				super.finishedChild(node, childIndex, hasMoreChildren);
+			}
+		} catch (IOException ioex) {
+			throw new CayenneRuntimeException("Error appending content", ioex);
+		}
+	}
+
+	private void finishedChildNodeAppendExpression(Expression node, String operation) throws IOException {
+		Appendable buf = matchingObject ? new StringBuilder() : this.out;
+		buf.append(operation);
+		if (matchingObject) {
+			objectMatchTranslator.setOperation(buf.toString());
+			objectMatchTranslator.setExpression(node);
+		}
+	}
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/81f4fb50/cayenne-server/src/main/java/org/apache/cayenne/dba/postgres/PostgresSelectAction.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/dba/postgres/PostgresSelectAction.java b/cayenne-server/src/main/java/org/apache/cayenne/dba/postgres/PostgresSelectAction.java
index 0833f96..b9e8fe5 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/dba/postgres/PostgresSelectAction.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/dba/postgres/PostgresSelectAction.java
@@ -18,8 +18,6 @@
  ****************************************************************/
 package org.apache.cayenne.dba.postgres;
 
-import java.sql.Connection;
-
 import org.apache.cayenne.access.DataNode;
 import org.apache.cayenne.access.jdbc.SelectAction;
 import org.apache.cayenne.access.translator.select.SelectTranslator;
@@ -30,17 +28,17 @@ import org.apache.cayenne.query.SelectQuery;
  */
 class PostgresSelectAction extends SelectAction {
 
-    <T> PostgresSelectAction(SelectQuery<T> query, DataNode dataNode) {
-        super(query, dataNode);
-    }
+	<T> PostgresSelectAction(SelectQuery<T> query, DataNode dataNode) {
+		super(query, dataNode);
+	}
 
-    @Override
-    protected int getInMemoryOffset(int queryOffset) {
-        return 0;
-    }
+	@Override
+	protected int getInMemoryOffset(int queryOffset) {
+		return 0;
+	}
 
-    @Override
-    protected SelectTranslator createTranslator(Connection connection) {
-        return new PostgresSelectTranslator(query, dataNode, connection);
-    }
+	@Override
+	protected SelectTranslator createTranslator() {
+		return new PostgresSelectTranslator(query, dataNode.getAdapter(), dataNode.getEntityResolver());
+	}
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/81f4fb50/cayenne-server/src/main/java/org/apache/cayenne/dba/postgres/PostgresSelectTranslator.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/dba/postgres/PostgresSelectTranslator.java b/cayenne-server/src/main/java/org/apache/cayenne/dba/postgres/PostgresSelectTranslator.java
index 84b3521..b7c1917 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/dba/postgres/PostgresSelectTranslator.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/dba/postgres/PostgresSelectTranslator.java
@@ -19,23 +19,22 @@
 
 package org.apache.cayenne.dba.postgres;
 
-import java.sql.Connection;
-
-import org.apache.cayenne.access.DataNode;
 import org.apache.cayenne.access.jdbc.ColumnDescriptor;
-import org.apache.cayenne.access.translator.select.SelectTranslator;
+import org.apache.cayenne.access.translator.select.DefaultSelectTranslator;
+import org.apache.cayenne.dba.DbAdapter;
+import org.apache.cayenne.map.EntityResolver;
 import org.apache.cayenne.query.Query;
 
 /**
  * @since 1.2
  */
-class PostgresSelectTranslator extends SelectTranslator {
+class PostgresSelectTranslator extends DefaultSelectTranslator {
 
 	/**
 	 * @since 4.0
 	 */
-	public PostgresSelectTranslator(Query query, DataNode dataNode, Connection connection) {
-		super(query, dataNode, connection);
+	public PostgresSelectTranslator(Query query, DbAdapter adapter, EntityResolver entityResolver) {
+		super(query, adapter, entityResolver);
 	}
 
 	@Override
@@ -81,7 +80,7 @@ class PostgresSelectTranslator extends SelectTranslator {
 		if (foundKey) {
 			builder.append(")");
 		}
-		
+
 		return builder.toString();
 	}
 

http://git-wip-us.apache.org/repos/asf/cayenne/blob/81f4fb50/cayenne-server/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerSelectAction.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerSelectAction.java b/cayenne-server/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerSelectAction.java
index d274d70..413a6a6 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerSelectAction.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerSelectAction.java
@@ -18,8 +18,6 @@
  ****************************************************************/
 package org.apache.cayenne.dba.sqlserver;
 
-import java.sql.Connection;
-
 import org.apache.cayenne.access.DataNode;
 import org.apache.cayenne.access.jdbc.SelectAction;
 import org.apache.cayenne.access.translator.select.SelectTranslator;
@@ -32,8 +30,8 @@ public class SQLServerSelectAction extends SelectAction {
     }
 
     @Override
-    protected SelectTranslator createTranslator(Connection connection) {
-        return new SQLServerSelectTranslator(query, dataNode, connection);
+    protected SelectTranslator createTranslator() {
+        return new SQLServerSelectTranslator(query, dataNode.getAdapter(), dataNode.getEntityResolver());
     }
 
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/81f4fb50/cayenne-server/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerSelectTranslator.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerSelectTranslator.java b/cayenne-server/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerSelectTranslator.java
index 3556c7b..b78877c 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerSelectTranslator.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerSelectTranslator.java
@@ -18,40 +18,37 @@
  ****************************************************************/
 package org.apache.cayenne.dba.sqlserver;
 
-import java.sql.Connection;
-
-import org.apache.cayenne.access.DataNode;
-import org.apache.cayenne.access.translator.select.SelectTranslator;
+import org.apache.cayenne.access.translator.select.DefaultSelectTranslator;
+import org.apache.cayenne.dba.DbAdapter;
+import org.apache.cayenne.map.EntityResolver;
 import org.apache.cayenne.query.Query;
-import org.apache.cayenne.query.QueryMetadata;
-
-public class SQLServerSelectTranslator extends SelectTranslator {
-	
-    /**
-     * @since 4.0
-     */
-    public SQLServerSelectTranslator(Query query, DataNode dataNode, Connection connection) {
-        super(query, dataNode, connection);
-    }
-    
-    @Override
-    protected void appendLimitAndOffsetClauses(StringBuilder buffer) {
-        QueryMetadata metadata = getQuery().getMetaData(getEntityResolver());
-        
-        int limit = metadata.getFetchLimit();
-        int offset = metadata.getFetchOffset();
-        
-        if (limit > 0) {
-        	String sql = buffer.toString();
-        	
-        	// If contains distinct insert top limit after
-        	if (sql.startsWith("SELECT DISTINCT ")) {
-        		buffer.replace(0, 15, "SELECT DISTINCT TOP " + (offset + limit));	
-        		
-        	} else {
-        		buffer.replace(0, 6, "SELECT TOP " + (offset + limit));	
-        	}
-        }
-    }
+
+public class SQLServerSelectTranslator extends DefaultSelectTranslator {
+
+	/**
+	 * @since 4.0
+	 */
+	public SQLServerSelectTranslator(Query query, DbAdapter adapter, EntityResolver entityResolver) {
+		super(query, adapter, entityResolver);
+	}
+
+	@Override
+	protected void appendLimitAndOffsetClauses(StringBuilder buffer) {
+
+		int limit = queryMetadata.getFetchLimit();
+		int offset = queryMetadata.getFetchOffset();
+
+		if (limit > 0) {
+			String sql = buffer.toString();
+
+			// If contains distinct insert top limit after
+			if (sql.startsWith("SELECT DISTINCT ")) {
+				buffer.replace(0, 15, "SELECT DISTINCT TOP " + (offset + limit));
+
+			} else {
+				buffer.replace(0, 6, "SELECT TOP " + (offset + limit));
+			}
+		}
+	}
 
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/81f4fb50/cayenne-server/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerTrimmingQualifierTranslator.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerTrimmingQualifierTranslator.java b/cayenne-server/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerTrimmingQualifierTranslator.java
index 2c0649f..0b4fa68 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerTrimmingQualifierTranslator.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerTrimmingQualifierTranslator.java
@@ -18,7 +18,6 @@
  ****************************************************************/
 package org.apache.cayenne.dba.sqlserver;
 
-import java.io.IOException;
 import java.sql.Types;
 import java.util.ArrayList;
 import java.util.List;
@@ -33,87 +32,84 @@ import org.apache.cayenne.map.DbAttribute;
  */
 class SQLServerTrimmingQualifierTranslator extends TrimmingQualifierTranslator {
 
-    // since LIKE IGNORE CASE requires more contextual information than the super
-    // translator can provide, we are using an internal element stack to trace translation
-    // context.. Maybe it is a good idea to introduce it in the superclass?
-    private List<Expression> expressionStack;
-
-    SQLServerTrimmingQualifierTranslator(QueryAssembler queryAssembler,
-            String trimFunction) {
-        super(queryAssembler, trimFunction);
-        expressionStack = new ArrayList<Expression>();
-    }
-
-    @Override
-    public void startNode(Expression node, Expression parentNode) {
-        push(node);
-        super.startNode(node, parentNode);
-    }
-
-    @Override
-    protected void processColumn(DbAttribute dbAttr) throws IOException {
-
-        Expression node = peek(1);
-
-        boolean likeCI = node != null
-                && dbAttr.getType() == Types.CLOB
-                && (node.getType() == Expression.LIKE_IGNORE_CASE || node.getType() == Expression.NOT_LIKE_IGNORE_CASE);
-
-        if (likeCI) {
-            out.append("CAST(");
-        }
-
-        super.processColumn(dbAttr);
-
-        if (likeCI) {
-            out.append(" AS NVARCHAR(MAX))");
-        }
-    }
-
-    @Override
-    protected void processColumnWithQuoteSqlIdentifiers(
-            DbAttribute dbAttr,
-            Expression pathExp) throws IOException {
-        Expression node = peek(1);
-
-        boolean likeCI = node != null
-                && dbAttr.getType() == Types.CLOB
-                && (node.getType() == Expression.LIKE_IGNORE_CASE || node.getType() == Expression.NOT_LIKE_IGNORE_CASE);
-
-        if (likeCI) {
-            out.append("CAST(");
-        }
-
-        super.processColumnWithQuoteSqlIdentifiers(dbAttr, node);
-
-        if (likeCI) {
-            out.append(" AS NVARCHAR(MAX))");
-        }
-    }
-
-    @Override
-    public void endNode(Expression node, Expression parentNode) {
-        super.endNode(node, parentNode);
-        pop();
-    }
-
-    private void push(Expression node) {
-        expressionStack.add(node);
-    }
-
-    private void pop() {
-        int len = expressionStack.size();
-        if (len > 0) {
-            expressionStack.remove(len - 1);
-        }
-    }
-
-    private Expression peek(int tailIndex) {
-        int index = expressionStack.size() - tailIndex - 1;
-        if (index < 0) {
-            return null;
-        }
-
-        return expressionStack.get(index);
-    }
+	// since LIKE IGNORE CASE requires more contextual information than the
+	// super
+	// translator can provide, we are using an internal element stack to trace
+	// translation
+	// context.. Maybe it is a good idea to introduce it in the superclass?
+	private List<Expression> expressionStack;
+
+	SQLServerTrimmingQualifierTranslator(QueryAssembler queryAssembler, String trimFunction) {
+		super(queryAssembler, trimFunction);
+		expressionStack = new ArrayList<Expression>();
+	}
+
+	@Override
+	public void startNode(Expression node, Expression parentNode) {
+		push(node);
+		super.startNode(node, parentNode);
+	}
+
+	@Override
+	protected void processColumn(DbAttribute dbAttr) {
+
+		Expression node = peek(1);
+
+		boolean likeCI = node != null && dbAttr.getType() == Types.CLOB
+				&& (node.getType() == Expression.LIKE_IGNORE_CASE || node.getType() == Expression.NOT_LIKE_IGNORE_CASE);
+
+		if (likeCI) {
+			out.append("CAST(");
+		}
+
+		super.processColumn(dbAttr);
+
+		if (likeCI) {
+			out.append(" AS NVARCHAR(MAX))");
+		}
+	}
+
+	@Override
+	protected void processColumnWithQuoteSqlIdentifiers(DbAttribute dbAttr, Expression pathExp) {
+		Expression node = peek(1);
+
+		boolean likeCI = node != null && dbAttr.getType() == Types.CLOB
+				&& (node.getType() == Expression.LIKE_IGNORE_CASE || node.getType() == Expression.NOT_LIKE_IGNORE_CASE);
+
+		if (likeCI) {
+			out.append("CAST(");
+		}
+
+		super.processColumnWithQuoteSqlIdentifiers(dbAttr, node);
+
+		if (likeCI) {
+			out.append(" AS NVARCHAR(MAX))");
+		}
+	}
+
+	@Override
+	public void endNode(Expression node, Expression parentNode) {
+		super.endNode(node, parentNode);
+		pop();
+	}
+
+	private void push(Expression node) {
+		expressionStack.add(node);
+	}
+
+	private void pop() {
+		int len = expressionStack.size();
+		if (len > 0) {
+			expressionStack.remove(len - 1);
+		}
+	}
+
+	private Expression peek(int tailIndex) {
+		int index = expressionStack.size() - tailIndex - 1;
+		if (index < 0) {
+			return null;
+		}
+
+		return expressionStack.get(index);
+	}
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/81f4fb50/cayenne-server/src/main/java/org/apache/cayenne/log/CommonsJdbcEventLogger.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/log/CommonsJdbcEventLogger.java b/cayenne-server/src/main/java/org/apache/cayenne/log/CommonsJdbcEventLogger.java
index 43cd923..d31f89f 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/log/CommonsJdbcEventLogger.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/log/CommonsJdbcEventLogger.java
@@ -25,8 +25,8 @@ import java.util.List;
 
 import org.apache.cayenne.CayenneRuntimeException;
 import org.apache.cayenne.ExtendedEnumeration;
-import org.apache.cayenne.access.jdbc.ParameterBinding;
-import org.apache.cayenne.access.translator.batch.BatchParameterBinding;
+import org.apache.cayenne.access.jdbc.SQLParameterBinding;
+import org.apache.cayenne.access.translator.ParameterBinding;
 import org.apache.cayenne.configuration.Constants;
 import org.apache.cayenne.configuration.RuntimeProperties;
 import org.apache.cayenne.conn.DataSourceInfo;
@@ -44,397 +44,426 @@ import org.apache.commons.logging.LogFactory;
  */
 public class CommonsJdbcEventLogger implements JdbcEventLogger {
 
-    private static final Log logger = LogFactory.getLog(CommonsJdbcEventLogger.class);
-
-    private static final int TRIM_VALUES_THRESHOLD = 30;
-
-    protected long queryExecutionTimeLoggingThreshold;
-
-    public CommonsJdbcEventLogger(@Inject RuntimeProperties runtimeProperties) {
-        this.queryExecutionTimeLoggingThreshold = runtimeProperties.getLong(
-                Constants.QUERY_EXECUTION_TIME_LOGGING_THRESHOLD_PROPERTY, 0);
-    }
-
-    void sqlLiteralForObject(StringBuilder buffer, Object object) {
-        if (object == null) {
-            buffer.append("NULL");
-        } else if (object instanceof String) {
-            buffer.append('\'');
-            // lets escape quotes
-            String literal = (String) object;
-            if (literal.length() > TRIM_VALUES_THRESHOLD) {
-                literal = literal.substring(0, TRIM_VALUES_THRESHOLD) + "...";
-            }
-
-            int curPos = 0;
-            int endPos = 0;
-
-            while ((endPos = literal.indexOf('\'', curPos)) >= 0) {
-                buffer.append(literal.substring(curPos, endPos + 1)).append('\'');
-                curPos = endPos + 1;
-            }
-
-            if (curPos < literal.length())
-                buffer.append(literal.substring(curPos));
-
-            buffer.append('\'');
-        }
-        // handle byte pretty formatting
-        else if (object instanceof Byte) {
-            IDUtil.appendFormattedByte(buffer, ((Byte) object).byteValue());
-        } else if (object instanceof Number) {
-            // process numeric value (do something smart in the future)
-            buffer.append(object);
-        } else if (object instanceof java.sql.Date) {
-            buffer.append('\'').append(object).append('\'');
-        } else if (object instanceof java.sql.Time) {
-            buffer.append('\'').append(object).append('\'');
-        } else if (object instanceof java.util.Date) {
-            long time = ((java.util.Date) object).getTime();
-            buffer.append('\'').append(new java.sql.Timestamp(time)).append('\'');
-        } else if (object instanceof java.util.Calendar) {
-            long time = ((java.util.Calendar) object).getTimeInMillis();
-            buffer.append(object.getClass().getName()).append('(').append(new java.sql.Timestamp(time)).append(')');
-        } else if (object instanceof Character) {
-            buffer.append(((Character) object).charValue());
-        } else if (object instanceof Boolean) {
-            buffer.append('\'').append(object).append('\'');
-        } else if (object instanceof Enum<?>) {
-            // buffer.append(object.getClass().getName()).append(".");
-            buffer.append(((Enum<?>) object).name()).append("=");
-            if (object instanceof ExtendedEnumeration) {
-                Object value = ((ExtendedEnumeration) object).getDatabaseValue();
-                if (value instanceof String)
-                    buffer.append("'");
-                buffer.append(value);
-                if (value instanceof String)
-                    buffer.append("'");
-            } else {
-                buffer.append(((Enum<?>) object).ordinal());
-                // FIXME -- this isn't quite right
-            }
-        } else if (object instanceof ParameterBinding) {
-            sqlLiteralForObject(buffer, ((ParameterBinding) object).getValue());
-        } else if (object.getClass().isArray()) {
-            buffer.append("< ");
-
-            int len = Array.getLength(object);
-            boolean trimming = false;
-            if (len > TRIM_VALUES_THRESHOLD) {
-                len = TRIM_VALUES_THRESHOLD;
-                trimming = true;
-            }
-
-            for (int i = 0; i < len; i++) {
-                if (i > 0) {
-                    buffer.append(",");
-                }
-                sqlLiteralForObject(buffer, Array.get(object, i));
-            }
-
-            if (trimming) {
-                buffer.append("...");
-            }
-
-            buffer.append('>');
-        } else {
-            buffer.append(object.getClass().getName()).append("@").append(System.identityHashCode(object));
-        }
-    }
-
-    @Override
-    public void log(String message) {
-        if (message != null) {
-            logger.info(message);
-        }
-    }
-
-    @Override
-    public void logConnect(String dataSource) {
-        if (isLoggable()) {
-            logger.info("Connecting. JNDI path: " + dataSource);
-        }
-    }
-
-    @Override
-    public void logConnect(String url, String userName, String password) {
-        if (isLoggable()) {
-            StringBuilder buf = new StringBuilder("Opening connection: ");
-
-            // append URL on the same line to make log somewhat grep-friendly
-            buf.append(url);
-            buf.append("\n\tLogin: ").append(userName);
-            buf.append("\n\tPassword: *******");
-
-            logger.info(buf.toString());
-        }
-    }
-
-    @Override
-    public void logPoolCreated(DataSourceInfo dsi) {
-        if (isLoggable()) {
-            StringBuilder buf = new StringBuilder("Created connection pool: ");
-
-            if (dsi != null) {
-                // append URL on the same line to make log somewhat
-                // grep-friendly
-                buf.append(dsi.getDataSourceUrl());
-
-                if (dsi.getAdapterClassName() != null) {
-                    buf.append("\n\tCayenne DbAdapter: ").append(dsi.getAdapterClassName());
-                }
-
-                buf.append("\n\tDriver class: ").append(dsi.getJdbcDriver());
-
-                if (dsi.getMinConnections() >= 0) {
-                    buf.append("\n\tMin. connections in the pool: ").append(dsi.getMinConnections());
-                }
-                if (dsi.getMaxConnections() >= 0) {
-                    buf.append("\n\tMax. connections in the pool: ").append(dsi.getMaxConnections());
-                }
-            } else {
-                buf.append(" pool information unavailable");
-            }
-
-            logger.info(buf.toString());
-        }
-    }
-
-    @Override
-    public void logConnectSuccess() {
-        logger.info("+++ Connecting: SUCCESS.");
-    }
-
-    @Override
-    public void logConnectFailure(Throwable th) {
-        logger.info("*** Connecting: FAILURE.", th);
-    }
-
-    @Override
-    public void logGeneratedKey(DbAttribute attribute, Object value) {
-        if (isLoggable()) {
-            String entity = attribute.getEntity().getName();
-            String key = attribute.getName();
-
-            logger.info("Generated PK: " + entity + "." + key + " = " + value);
-        }
-    }
-
-    @Override
-    public void logQuery(String queryStr, List<?> params) {
-        logQuery(queryStr, null, params, -1);
-    }
-
-    @Deprecated
-    private void buildLog(StringBuilder buffer, String prefix, String postfix, List<DbAttribute> attributes,
-            List<?> parameters, boolean isInserting) {
-        if (parameters != null && parameters.size() > 0) {
-            DbAttribute attribute = null;
-            Iterator<DbAttribute> attributeIterator = null;
-            int position = 0;
-
-            if (attributes != null)
-                attributeIterator = attributes.iterator();
-
-            for (Object parameter : parameters) {
-                // If at the beginning, output the prefix, otherwise a
-                // separator.
-                if (position++ == 0)
-                    buffer.append(prefix);
-                else
-                    buffer.append(", ");
-
-                // Find the next attribute and SKIP generated attributes. Only
-                // skip when logging inserts, though. Should show previously
-                // generated keys on DELETE, UPDATE, or SELECT.
-                while (attributeIterator != null && attributeIterator.hasNext()) {
-                    attribute = attributeIterator.next();
-
-                    if (isInserting == false || attribute.isGenerated() == false)
-                        break;
-                }
-
-                buffer.append(position);
-
-                if (attribute != null) {
-                    buffer.append("->");
-                    buffer.append(attribute.getName());
-                }
-
-                buffer.append(":");
-                sqlLiteralForObject(buffer, parameter);
-            }
-
-            buffer.append(postfix);
-        }
-    }
-
-   
-
-    private boolean isInserting(String query) {
-        if (query == null || query.length() == 0)
-            return false;
-
-        char firstCharacter = query.charAt(0);
-
-        if (firstCharacter == 'I' || firstCharacter == 'i')
-            return true;
-        else
-            return false;
-    }
-
-    @Override
-    public void logQuery(String queryStr, List<DbAttribute> attrs, List<?> params, long time) {
-        if (isLoggable()) {
-            StringBuilder buffer = new StringBuilder(queryStr);
-            buildLog(buffer, " [bind: ", "]", attrs, params, isInserting(queryStr));
-
-            // log preparation time only if it is something significant
-            if (time > 5) {
-                buffer.append(" - prepared in ").append(time).append(" ms.");
-            }
-
-            logger.info(buffer.toString());
-        }
-    }
-
-    @Deprecated
-    @Override
-    public void logQueryParameters(String label, List<DbAttribute> attrs, List<Object> parameters, boolean isInserting) {
-        String prefix = "[" + label + ": ";
-        if (isLoggable() && parameters.size() > 0) {
-            StringBuilder buffer = new StringBuilder();
-            buildLog(buffer, prefix, "]", attrs, parameters, isInserting);
-            logger.info(buffer.toString());
-        }
-    }
-
-    @Override
-    public void logQueryParameters(String label, BatchParameterBinding[] bindings) {
-
-        if (isLoggable() && bindings.length > 0) {
-
-            boolean hasIncluded = false;
-            StringBuilder buffer = null;
-
-            int len = bindings.length;
-            for (int i = 0, j = 1; i < len; i++) {
-                BatchParameterBinding b = bindings[i];
-
-                if (b.isExcluded()) {
-                    continue;
-                }
-
-                if (hasIncluded) {
-                    buffer.append(", ");
-                } else {
-                    hasIncluded = true;
-                    buffer = new StringBuilder();
-                    buffer.append("[").append(label).append(": ");
-                }
-
-                DbAttribute attribute = b.getAttribute();
-
-                buffer.append(j++);
-
-                if (attribute != null) {
-                    buffer.append("->");
-                    buffer.append(attribute.getName());
-                }
-
-                buffer.append(":");
-                sqlLiteralForObject(buffer, b.getValue());
-            }
-
-            if (hasIncluded) {
-                buffer.append("]");
-
-                logger.info(buffer.toString());
-            }
-        }
-    }
-
-    @Override
-    public void logSelectCount(int count, long time) {
-        logSelectCount(count, time, null);
-    }
-
-    @Override
-    public void logSelectCount(int count, long time, String sql) {
-
-        if (isLoggable()) {
-            StringBuilder buf = new StringBuilder();
-
-            if (count == 1) {
-                buf.append("=== returned 1 row.");
-            } else {
-                buf.append("=== returned ").append(count).append(" rows.");
-            }
-
-            if (time >= 0) {
-                buf.append(" - took ").append(time).append(" ms.");
-            }
-
-            logger.info(buf.toString());
-        }
-
-        if (queryExecutionTimeLoggingThreshold > 0 && time > queryExecutionTimeLoggingThreshold) {
-            StringBuilder buf = new StringBuilder();
-            buf.append("Query time exceeded threshold (").append(time).append(" ms): ");
-            buf.append(sql);
-            String message = buf.toString();
-            logger.warn(message, new CayenneRuntimeException(message));
-        }
-    }
-
-    @Override
-    public void logUpdateCount(int count) {
-        if (isLoggable()) {
-            if (count < 0) {
-                logger.info("=== updated ? rows");
-            } else {
-                String countStr = (count == 1) ? "=== updated 1 row." : "=== updated " + count + " rows.";
-                logger.info(countStr);
-            }
-        }
-    }
-
-    @Override
-    public void logBeginTransaction(String transactionLabel) {
-        logger.info("--- " + transactionLabel);
-    }
-
-    @Override
-    public void logCommitTransaction(String transactionLabel) {
-        logger.info("+++ " + transactionLabel);
-    }
-
-    @Override
-    public void logRollbackTransaction(String transactionLabel) {
-        logger.info("*** " + transactionLabel);
-    }
-
-    @Override
-    public void logQueryError(Throwable th) {
-        if (isLoggable()) {
-            if (th != null) {
-                th = Util.unwindException(th);
-            }
-
-            logger.info("*** error.", th);
-
-            if (th instanceof SQLException) {
-                SQLException sqlException = ((SQLException) th).getNextException();
-                while (sqlException != null) {
-                    logger.info("*** nested SQL error.", sqlException);
-                    sqlException = sqlException.getNextException();
-                }
-            }
-        }
-    }
-
-    @Override
-    public boolean isLoggable() {
-        return logger.isInfoEnabled();
-    }
+	private static final Log logger = LogFactory.getLog(CommonsJdbcEventLogger.class);
+
+	private static final int TRIM_VALUES_THRESHOLD = 30;
+
+	protected long queryExecutionTimeLoggingThreshold;
+
+	public CommonsJdbcEventLogger(@Inject RuntimeProperties runtimeProperties) {
+		this.queryExecutionTimeLoggingThreshold = runtimeProperties.getLong(
+				Constants.QUERY_EXECUTION_TIME_LOGGING_THRESHOLD_PROPERTY, 0);
+	}
+
+	void sqlLiteralForObject(StringBuilder buffer, Object object) {
+		if (object == null) {
+			buffer.append("NULL");
+		} else if (object instanceof String) {
+			buffer.append('\'');
+			// lets escape quotes
+			String literal = (String) object;
+			if (literal.length() > TRIM_VALUES_THRESHOLD) {
+				literal = literal.substring(0, TRIM_VALUES_THRESHOLD) + "...";
+			}
+
+			int curPos = 0;
+			int endPos = 0;
+
+			while ((endPos = literal.indexOf('\'', curPos)) >= 0) {
+				buffer.append(literal.substring(curPos, endPos + 1)).append('\'');
+				curPos = endPos + 1;
+			}
+
+			if (curPos < literal.length())
+				buffer.append(literal.substring(curPos));
+
+			buffer.append('\'');
+		}
+		// handle byte pretty formatting
+		else if (object instanceof Byte) {
+			IDUtil.appendFormattedByte(buffer, ((Byte) object).byteValue());
+		} else if (object instanceof Number) {
+			// process numeric value (do something smart in the future)
+			buffer.append(object);
+		} else if (object instanceof java.sql.Date) {
+			buffer.append('\'').append(object).append('\'');
+		} else if (object instanceof java.sql.Time) {
+			buffer.append('\'').append(object).append('\'');
+		} else if (object instanceof java.util.Date) {
+			long time = ((java.util.Date) object).getTime();
+			buffer.append('\'').append(new java.sql.Timestamp(time)).append('\'');
+		} else if (object instanceof java.util.Calendar) {
+			long time = ((java.util.Calendar) object).getTimeInMillis();
+			buffer.append(object.getClass().getName()).append('(').append(new java.sql.Timestamp(time)).append(')');
+		} else if (object instanceof Character) {
+			buffer.append(((Character) object).charValue());
+		} else if (object instanceof Boolean) {
+			buffer.append('\'').append(object).append('\'');
+		} else if (object instanceof Enum<?>) {
+			// buffer.append(object.getClass().getName()).append(".");
+			buffer.append(((Enum<?>) object).name()).append("=");
+			if (object instanceof ExtendedEnumeration) {
+				Object value = ((ExtendedEnumeration) object).getDatabaseValue();
+				if (value instanceof String)
+					buffer.append("'");
+				buffer.append(value);
+				if (value instanceof String)
+					buffer.append("'");
+			} else {
+				buffer.append(((Enum<?>) object).ordinal());
+				// FIXME -- this isn't quite right
+			}
+		} else if (object instanceof SQLParameterBinding) {
+			sqlLiteralForObject(buffer, ((SQLParameterBinding) object).getValue());
+		} else if (object.getClass().isArray()) {
+			buffer.append("< ");
+
+			int len = Array.getLength(object);
+			boolean trimming = false;
+			if (len > TRIM_VALUES_THRESHOLD) {
+				len = TRIM_VALUES_THRESHOLD;
+				trimming = true;
+			}
+
+			for (int i = 0; i < len; i++) {
+				if (i > 0) {
+					buffer.append(",");
+				}
+				sqlLiteralForObject(buffer, Array.get(object, i));
+			}
+
+			if (trimming) {
+				buffer.append("...");
+			}
+
+			buffer.append('>');
+		} else {
+			buffer.append(object.getClass().getName()).append("@").append(System.identityHashCode(object));
+		}
+	}
+
+	@Override
+	public void log(String message) {
+		if (message != null) {
+			logger.info(message);
+		}
+	}
+
+	@Override
+	public void logConnect(String dataSource) {
+		if (isLoggable()) {
+			logger.info("Connecting. JNDI path: " + dataSource);
+		}
+	}
+
+	@Override
+	public void logConnect(String url, String userName, String password) {
+		if (isLoggable()) {
+			StringBuilder buf = new StringBuilder("Opening connection: ");
+
+			// append URL on the same line to make log somewhat grep-friendly
+			buf.append(url);
+			buf.append("\n\tLogin: ").append(userName);
+			buf.append("\n\tPassword: *******");
+
+			logger.info(buf.toString());
+		}
+	}
+
+	@Override
+	public void logPoolCreated(DataSourceInfo dsi) {
+		if (isLoggable()) {
+			StringBuilder buf = new StringBuilder("Created connection pool: ");
+
+			if (dsi != null) {
+				// append URL on the same line to make log somewhat
+				// grep-friendly
+				buf.append(dsi.getDataSourceUrl());
+
+				if (dsi.getAdapterClassName() != null) {
+					buf.append("\n\tCayenne DbAdapter: ").append(dsi.getAdapterClassName());
+				}
+
+				buf.append("\n\tDriver class: ").append(dsi.getJdbcDriver());
+
+				if (dsi.getMinConnections() >= 0) {
+					buf.append("\n\tMin. connections in the pool: ").append(dsi.getMinConnections());
+				}
+				if (dsi.getMaxConnections() >= 0) {
+					buf.append("\n\tMax. connections in the pool: ").append(dsi.getMaxConnections());
+				}
+			} else {
+				buf.append(" pool information unavailable");
+			}
+
+			logger.info(buf.toString());
+		}
+	}
+
+	@Override
+	public void logConnectSuccess() {
+		logger.info("+++ Connecting: SUCCESS.");
+	}
+
+	@Override
+	public void logConnectFailure(Throwable th) {
+		logger.info("*** Connecting: FAILURE.", th);
+	}
+
+	@Override
+	public void logGeneratedKey(DbAttribute attribute, Object value) {
+		if (isLoggable()) {
+			String entity = attribute.getEntity().getName();
+			String key = attribute.getName();
+
+			logger.info("Generated PK: " + entity + "." + key + " = " + value);
+		}
+	}
+
+	/**
+	 * @deprecated since 4.0 use
+	 *             {@link #logQuery(String, ParameterBinding[], long)}.
+	 */
+	@Deprecated
+	@Override
+	public void logQuery(String queryStr, List<?> params) {
+		logQuery(queryStr, null, params, -1);
+	}
+
+	/**
+	 * @deprecated since 4.0 uses old style of parameter logging.
+	 */
+	@Deprecated
+	private void buildLog(StringBuilder buffer, String prefix, String postfix, List<DbAttribute> attributes,
+			List<?> parameters, boolean isInserting) {
+		if (parameters != null && parameters.size() > 0) {
+			Iterator<DbAttribute> attributeIterator = null;
+			int position = 0;
+
+			if (attributes != null)
+				attributeIterator = attributes.iterator();
+
+			for (Object parameter : parameters) {
+				// If at the beginning, output the prefix, otherwise a
+				// separator.
+				if (position++ == 0)
+					buffer.append(prefix);
+				else
+					buffer.append(", ");
+
+				// Find the next attribute and SKIP generated attributes. Only
+				// skip when logging inserts, though. Should show previously
+				// generated keys on DELETE, UPDATE, or SELECT.
+				DbAttribute attribute = null;
+				while (attributeIterator != null && attributeIterator.hasNext()) {
+					attribute = attributeIterator.next();
+
+					if (isInserting == false || attribute.isGenerated() == false)
+						break;
+				}
+
+				buffer.append(position);
+
+				if (attribute != null) {
+					buffer.append("->");
+					buffer.append(attribute.getName());
+				}
+
+				buffer.append(":");
+				sqlLiteralForObject(buffer, parameter);
+			}
+
+			buffer.append(postfix);
+		}
+	}
+
+	private boolean isInserting(String query) {
+		if (query == null || query.length() == 0)
+			return false;
+
+		char firstCharacter = query.charAt(0);
+
+		if (firstCharacter == 'I' || firstCharacter == 'i')
+			return true;
+		else
+			return false;
+	}
+
+	@Override
+	public void logQuery(String sql, ParameterBinding[] bindings, long translatedIn) {
+		if (isLoggable()) {
+
+			StringBuilder buffer = new StringBuilder(sql).append(" ");
+			appendParameters(buffer, "bind", bindings);
+
+			if (buffer.length() > 0) {
+				logger.info(buffer.toString());
+			}
+		}
+	}
+
+	@Deprecated
+	@Override
+	public void logQuery(String queryStr, List<DbAttribute> attrs, List<?> params, long time) {
+		if (isLoggable()) {
+			StringBuilder buffer = new StringBuilder(queryStr);
+			buildLog(buffer, " [bind: ", "]", attrs, params, isInserting(queryStr));
+
+			// log preparation time only if it is something significant
+			if (time > 5) {
+				buffer.append(" - prepared in ").append(time).append(" ms.");
+			}
+
+			logger.info(buffer.toString());
+		}
+	}
+
+	@Deprecated
+	@Override
+	public void logQueryParameters(String label, List<DbAttribute> attrs, List<Object> parameters, boolean isInserting) {
+		String prefix = "[" + label + ": ";
+		if (isLoggable() && parameters.size() > 0) {
+			StringBuilder buffer = new StringBuilder();
+			buildLog(buffer, prefix, "]", attrs, parameters, isInserting);
+			logger.info(buffer.toString());
+		}
+	}
+
+	@Override
+	public void logQueryParameters(String label, ParameterBinding[] bindings) {
+
+		if (isLoggable() && bindings.length > 0) {
+
+			StringBuilder buffer = new StringBuilder();
+			appendParameters(buffer, label, bindings);
+
+			if (buffer.length() > 0) {
+				logger.info(buffer.toString());
+			}
+		}
+	}
+
+	private void appendParameters(StringBuilder buffer, String label, ParameterBinding[] bindings) {
+
+		int len = bindings.length;
+		if (len > 0) {
+
+			boolean hasIncluded = false;
+
+			for (int i = 0, j = 1; i < len; i++) {
+				ParameterBinding b = bindings[i];
+
+				if (b.isExcluded()) {
+					continue;
+				}
+
+				if (hasIncluded) {
+					buffer.append(", ");
+				} else {
+					hasIncluded = true;
+					buffer.append("[").append(label).append(": ");
+				}
+
+				DbAttribute attribute = b.getAttribute();
+
+				buffer.append(j++);
+
+				if (attribute != null) {
+					buffer.append("->");
+					buffer.append(attribute.getName());
+				}
+
+				buffer.append(":");
+				sqlLiteralForObject(buffer, b.getValue());
+			}
+
+			if (hasIncluded) {
+				buffer.append("]");
+			}
+		}
+	}
+
+	@Override
+	public void logSelectCount(int count, long time) {
+		logSelectCount(count, time, null);
+	}
+
+	@Override
+	public void logSelectCount(int count, long time, String sql) {
+
+		if (isLoggable()) {
+			StringBuilder buf = new StringBuilder();
+
+			if (count == 1) {
+				buf.append("=== returned 1 row.");
+			} else {
+				buf.append("=== returned ").append(count).append(" rows.");
+			}
+
+			if (time >= 0) {
+				buf.append(" - took ").append(time).append(" ms.");
+			}
+
+			logger.info(buf.toString());
+		}
+
+		if (queryExecutionTimeLoggingThreshold > 0 && time > queryExecutionTimeLoggingThreshold) {
+			StringBuilder buf = new StringBuilder();
+			buf.append("Query time exceeded threshold (").append(time).append(" ms): ");
+			buf.append(sql);
+			String message = buf.toString();
+			logger.warn(message, new CayenneRuntimeException(message));
+		}
+	}
+
+	@Override
+	public void logUpdateCount(int count) {
+		if (isLoggable()) {
+			if (count < 0) {
+				logger.info("=== updated ? rows");
+			} else {
+				String countStr = (count == 1) ? "=== updated 1 row." : "=== updated " + count + " rows.";
+				logger.info(countStr);
+			}
+		}
+	}
+
+	@Override
+	public void logBeginTransaction(String transactionLabel) {
+		logger.info("--- " + transactionLabel);
+	}
+
+	@Override
+	public void logCommitTransaction(String transactionLabel) {
+		logger.info("+++ " + transactionLabel);
+	}
+
+	@Override
+	public void logRollbackTransaction(String transactionLabel) {
+		logger.info("*** " + transactionLabel);
+	}
+
+	@Override
+	public void logQueryError(Throwable th) {
+		if (isLoggable()) {
+			if (th != null) {
+				th = Util.unwindException(th);
+			}
+
+			logger.info("*** error.", th);
+
+			if (th instanceof SQLException) {
+				SQLException sqlException = ((SQLException) th).getNextException();
+				while (sqlException != null) {
+					logger.info("*** nested SQL error.", sqlException);
+					sqlException = sqlException.getNextException();
+				}
+			}
+		}
+	}
+
+	@Override
+	public boolean isLoggable() {
+		return logger.isInfoEnabled();
+	}
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/81f4fb50/cayenne-server/src/main/java/org/apache/cayenne/log/JdbcEventLogger.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/log/JdbcEventLogger.java b/cayenne-server/src/main/java/org/apache/cayenne/log/JdbcEventLogger.java
index 59e3f1e..7e89611 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/log/JdbcEventLogger.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/log/JdbcEventLogger.java
@@ -20,7 +20,7 @@ package org.apache.cayenne.log;
 
 import java.util.List;
 
-import org.apache.cayenne.access.translator.batch.BatchParameterBinding;
+import org.apache.cayenne.access.translator.ParameterBinding;
 import org.apache.cayenne.conn.DataSourceInfo;
 import org.apache.cayenne.map.DbAttribute;
 
@@ -54,18 +54,33 @@ public interface JdbcEventLogger {
 
 	void logGeneratedKey(DbAttribute attribute, Object value);
 
+	/**
+	 * @deprecated since 4.0 use
+	 *             {@link #logQuery(String, ParameterBinding[], long)}.
+	 */
+	@Deprecated
 	void logQuery(String sql, List<?> params);
 
+	/**
+	 * @deprecated since 4.0 use
+	 *             {@link #logQuery(String, ParameterBinding[], long)}.
+	 */
+	@Deprecated
 	void logQuery(String sql, List<DbAttribute> attrs, List<?> params, long time);
 
 	/**
 	 * @since 4.0
 	 */
-	void logQueryParameters(String label, BatchParameterBinding[] bindings);
+	void logQuery(String sql, ParameterBinding[] bindings, long translatedIn);
+
+	/**
+	 * @since 4.0
+	 */
+	void logQueryParameters(String label, ParameterBinding[] bindings);
 
 	/**
 	 * @deprecated since 4.0 in favor of
-	 *             {@link #logQueryParameters(String, BatchParameterBinding[])}
+	 *             {@link #logQueryParameters(String, ParameterBinding[])}
 	 */
 	@Deprecated
 	void logQueryParameters(String label, List<DbAttribute> attrs, List<Object> parameters, boolean isInserting);

http://git-wip-us.apache.org/repos/asf/cayenne/blob/81f4fb50/cayenne-server/src/main/java/org/apache/cayenne/log/NoopJdbcEventLogger.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/log/NoopJdbcEventLogger.java b/cayenne-server/src/main/java/org/apache/cayenne/log/NoopJdbcEventLogger.java
index 5db1115..03f29ab 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/log/NoopJdbcEventLogger.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/log/NoopJdbcEventLogger.java
@@ -20,7 +20,7 @@ package org.apache.cayenne.log;
 
 import java.util.List;
 
-import org.apache.cayenne.access.translator.batch.BatchParameterBinding;
+import org.apache.cayenne.access.translator.ParameterBinding;
 import org.apache.cayenne.conn.DataSourceInfo;
 import org.apache.cayenne.map.DbAttribute;
 
@@ -29,78 +29,96 @@ import org.apache.cayenne.map.DbAttribute;
  */
 public class NoopJdbcEventLogger implements JdbcEventLogger {
 
-    private static final NoopJdbcEventLogger instance = new NoopJdbcEventLogger();
+	private static final NoopJdbcEventLogger instance = new NoopJdbcEventLogger();
 
-    public static NoopJdbcEventLogger getInstance() {
-        return instance;
-    }
+	public static NoopJdbcEventLogger getInstance() {
+		return instance;
+	}
 
-    private NoopJdbcEventLogger() {
+	private NoopJdbcEventLogger() {
 
-    }
+	}
 
-    public void log(String message) {
-    }
+	@Override
+	public void log(String message) {
+	}
 
-    public void logConnect(String dataSource) {
-    }
+	@Override
+	public void logConnect(String dataSource) {
+	}
 
-    public void logConnect(String url, String userName, String password) {
-    }
+	@Override
+	public void logConnect(String url, String userName, String password) {
+	}
 
-    public void logPoolCreated(DataSourceInfo dsi) {
-    }
+	@Override
+	public void logPoolCreated(DataSourceInfo dsi) {
+	}
 
-    public void logConnectSuccess() {
-    }
+	@Override
+	public void logConnectSuccess() {
+	}
 
-    public void logConnectFailure(Throwable th) {
-    }
+	@Override
+	public void logConnectFailure(Throwable th) {
+	}
 
-    public void logGeneratedKey(DbAttribute attribute, Object value) {
-    }
+	@Override
+	public void logGeneratedKey(DbAttribute attribute, Object value) {
+	}
 
-    public void logQuery(String sql, List<?> params) {
-    }
+	@Override
+	public void logQuery(String sql, List<?> params) {
+	}
 
-    public void logQuery(String sql, List<DbAttribute> attrs, List<?> params, long time) {
-    }
-
-    @Override
-    @Deprecated
-    public void logQueryParameters(
-            String label,
-            List<DbAttribute> attrs,
-            List<Object> parameters,
-            boolean isInserting) {
-    }
-    
-    @Override
-    public void logQueryParameters(String label, BatchParameterBinding[] bindings) {
-    }
-
-    public void logSelectCount(int count, long time) {
-    }
-
-    public void logSelectCount(int count, long time, String sql) {
-    }
+	@Deprecated
+	@Override
+	public void logQuery(String sql, List<DbAttribute> attrs, List<?> params, long time) {
+	}
 	
-    public void logUpdateCount(int count) {
-    }
-
-    public void logBeginTransaction(String transactionLabel) {
-    }
-
-    public void logCommitTransaction(String transactionLabel) {
-    }
-
-    public void logRollbackTransaction(String transactionLabel) {
-    }
-
-    public void logQueryError(Throwable th) {
-    }
-
-    public boolean isLoggable() {
-        return false;
-    }
+	@Override
+	public void logQuery(String sql, ParameterBinding[] bindings, long translatedIn) {		
+	}
+
+	@Override
+	@Deprecated
+	public void logQueryParameters(String label, List<DbAttribute> attrs, List<Object> parameters, boolean isInserting) {
+	}
+
+	@Override
+	public void logQueryParameters(String label, ParameterBinding[] bindings) {
+	}
+
+	@Override
+	public void logSelectCount(int count, long time) {
+	}
+
+	@Override
+	public void logSelectCount(int count, long time, String sql) {
+	}
+
+	@Override
+	public void logUpdateCount(int count) {
+	}
+
+	@Override
+	public void logBeginTransaction(String transactionLabel) {
+	}
+
+	@Override
+	public void logCommitTransaction(String transactionLabel) {
+	}
+
+	@Override
+	public void logRollbackTransaction(String transactionLabel) {
+	}
+
+	@Override
+	public void logQueryError(Throwable th) {
+	}
+
+	@Override
+	public boolean isLoggable() {
+		return false;
+	}
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/81f4fb50/cayenne-server/src/main/java/org/apache/cayenne/merge/DefaultValueForNullProvider.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/merge/DefaultValueForNullProvider.java b/cayenne-server/src/main/java/org/apache/cayenne/merge/DefaultValueForNullProvider.java
index ae63f53..6db83c0 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/merge/DefaultValueForNullProvider.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/merge/DefaultValueForNullProvider.java
@@ -23,25 +23,25 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import org.apache.cayenne.access.jdbc.ParameterBinding;
+import org.apache.cayenne.access.jdbc.SQLParameterBinding;
 import org.apache.cayenne.map.DbAttribute;
 import org.apache.cayenne.map.DbEntity;
 
 public class DefaultValueForNullProvider implements ValueForNullProvider {
 
-    private Map<String, ParameterBinding> values = new HashMap<String, ParameterBinding>();
+    private Map<String, SQLParameterBinding> values = new HashMap<String, SQLParameterBinding>();
 
     public void set(DbEntity entity, DbAttribute column, Object value, int type) {
-        values.put(createKey(entity, column), new ParameterBinding(value, type, column
+        values.put(createKey(entity, column), new SQLParameterBinding(value, type, column
                 .getAttributePrecision()));
     }
 
-    protected ParameterBinding get(DbEntity entity, DbAttribute column) {
+    protected SQLParameterBinding get(DbEntity entity, DbAttribute column) {
         return values.get(createKey(entity, column));
     }
 
     public List<String> createSql(DbEntity entity, DbAttribute column) {
-        ParameterBinding value = get(entity, column);
+        SQLParameterBinding value = get(entity, column);
         if (value == null) {
             return Collections.emptyList();
         }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/81f4fb50/cayenne-server/src/main/java/org/apache/cayenne/velocity/BindDirective.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/velocity/BindDirective.java b/cayenne-server/src/main/java/org/apache/cayenne/velocity/BindDirective.java
index 43e807a..8529a77 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/velocity/BindDirective.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/velocity/BindDirective.java
@@ -24,7 +24,7 @@ import java.io.Writer;
 import java.util.Collection;
 import java.util.Iterator;
 
-import org.apache.cayenne.access.jdbc.ParameterBinding;
+import org.apache.cayenne.access.jdbc.SQLParameterBinding;
 import org.apache.cayenne.dba.TypesMapping;
 import org.apache.cayenne.util.ConversionUtil;
 import org.apache.velocity.context.InternalContextAdapter;
@@ -81,7 +81,7 @@ public class BindDirective extends Directive {
 
 	/**
 	 * Extracts the value of the object property to render and passes control to
-	 * {@link #render(InternalContextAdapter, Writer, ParameterBinding)} to do
+	 * {@link #render(InternalContextAdapter, Writer, SQLParameterBinding)} to do
 	 * the actual rendering.
 	 */
 	@Override
@@ -130,10 +130,10 @@ public class BindDirective extends Directive {
 					+ ") at line " + node.getLine() + ", column " + node.getColumn());
 		}
 
-		render(context, writer, new ParameterBinding(value, jdbcType, scale));
+		render(context, writer, new SQLParameterBinding(value, jdbcType, scale));
 	}
 
-	protected void render(InternalContextAdapter context, Writer writer, ParameterBinding binding) throws IOException {
+	protected void render(InternalContextAdapter context, Writer writer, SQLParameterBinding binding) throws IOException {
 
 		bind(context, binding);
 		writer.write('?');
@@ -146,7 +146,7 @@ public class BindDirective extends Directive {
 	/**
 	 * Adds value to the list of bindings in the context.
 	 */
-	protected void bind(InternalContextAdapter context, ParameterBinding binding) {
+	protected void bind(InternalContextAdapter context, SQLParameterBinding binding) {
 
 		Collection bindings = (Collection) context.getInternalUserContext().get(
 				VelocitySQLTemplateProcessor.BINDINGS_LIST_KEY);

http://git-wip-us.apache.org/repos/asf/cayenne/blob/81f4fb50/cayenne-server/src/main/java/org/apache/cayenne/velocity/BindEqualDirective.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/velocity/BindEqualDirective.java b/cayenne-server/src/main/java/org/apache/cayenne/velocity/BindEqualDirective.java
index b773cf5..f109b82 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/velocity/BindEqualDirective.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/velocity/BindEqualDirective.java
@@ -22,7 +22,7 @@ package org.apache.cayenne.velocity;
 import java.io.IOException;
 import java.io.Writer;
 
-import org.apache.cayenne.access.jdbc.ParameterBinding;
+import org.apache.cayenne.access.jdbc.SQLParameterBinding;
 import org.apache.velocity.context.InternalContextAdapter;
 
 /**
@@ -43,7 +43,7 @@ public class BindEqualDirective extends BindDirective {
     protected void render(
         InternalContextAdapter context,
         Writer writer,
-        ParameterBinding binding)
+        SQLParameterBinding binding)
         throws IOException {
 
         if (binding.getValue() != null) {

http://git-wip-us.apache.org/repos/asf/cayenne/blob/81f4fb50/cayenne-server/src/main/java/org/apache/cayenne/velocity/BindNotEqualDirective.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/velocity/BindNotEqualDirective.java b/cayenne-server/src/main/java/org/apache/cayenne/velocity/BindNotEqualDirective.java
index a49a8d6..3b17732 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/velocity/BindNotEqualDirective.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/velocity/BindNotEqualDirective.java
@@ -22,7 +22,7 @@ package org.apache.cayenne.velocity;
 import java.io.IOException;
 import java.io.Writer;
 
-import org.apache.cayenne.access.jdbc.ParameterBinding;
+import org.apache.cayenne.access.jdbc.SQLParameterBinding;
 import org.apache.velocity.context.InternalContextAdapter;
 
 /**
@@ -43,7 +43,7 @@ public class BindNotEqualDirective extends BindDirective {
     protected void render(
             InternalContextAdapter context,
             Writer writer,
-            ParameterBinding binding) throws IOException {
+            SQLParameterBinding binding) throws IOException {
 
         if (binding.getValue() != null) {
             bind(context, binding);

http://git-wip-us.apache.org/repos/asf/cayenne/blob/81f4fb50/cayenne-server/src/main/java/org/apache/cayenne/velocity/BindObjectEqualDirective.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/velocity/BindObjectEqualDirective.java b/cayenne-server/src/main/java/org/apache/cayenne/velocity/BindObjectEqualDirective.java
index ed1f7d0..35785d3 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/velocity/BindObjectEqualDirective.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/velocity/BindObjectEqualDirective.java
@@ -27,7 +27,7 @@ import java.util.Map;
 
 import org.apache.cayenne.ObjectId;
 import org.apache.cayenne.Persistent;
-import org.apache.cayenne.access.jdbc.ParameterBinding;
+import org.apache.cayenne.access.jdbc.SQLParameterBinding;
 import org.apache.cayenne.dba.TypesMapping;
 import org.apache.velocity.context.InternalContextAdapter;
 import org.apache.velocity.exception.MethodInvocationException;
@@ -94,7 +94,7 @@ public class BindObjectEqualDirective extends BindDirective {
 
             renderColumn(context, writer, sqlColumnsArray[i], i);
             writer.write(' ');
-            render(context, writer, new ParameterBinding(value, jdbcType, -1));
+            render(context, writer, new SQLParameterBinding(value, jdbcType, -1));
         }
 
         return true;
@@ -151,7 +151,7 @@ public class BindObjectEqualDirective extends BindDirective {
     protected void render(
             InternalContextAdapter context,
             Writer writer,
-            ParameterBinding binding) throws IOException {
+            SQLParameterBinding binding) throws IOException {
 
         if (binding.getValue() != null) {
             bind(context, binding);

http://git-wip-us.apache.org/repos/asf/cayenne/blob/81f4fb50/cayenne-server/src/main/java/org/apache/cayenne/velocity/BindObjectNotEqualDirective.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/velocity/BindObjectNotEqualDirective.java b/cayenne-server/src/main/java/org/apache/cayenne/velocity/BindObjectNotEqualDirective.java
index 0b610ab..bf76993 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/velocity/BindObjectNotEqualDirective.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/velocity/BindObjectNotEqualDirective.java
@@ -21,7 +21,7 @@ package org.apache.cayenne.velocity;
 import java.io.IOException;
 import java.io.Writer;
 
-import org.apache.cayenne.access.jdbc.ParameterBinding;
+import org.apache.cayenne.access.jdbc.SQLParameterBinding;
 import org.apache.velocity.context.InternalContextAdapter;
 
 /**
@@ -57,7 +57,7 @@ public class BindObjectNotEqualDirective extends BindObjectEqualDirective {
     protected void render(
             InternalContextAdapter context,
             Writer writer,
-            ParameterBinding binding) throws IOException {
+            SQLParameterBinding binding) throws IOException {
 
         if (binding.getValue() != null) {
             bind(context, binding);

http://git-wip-us.apache.org/repos/asf/cayenne/blob/81f4fb50/cayenne-server/src/main/java/org/apache/cayenne/velocity/VelocitySQLTemplateProcessor.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/velocity/VelocitySQLTemplateProcessor.java b/cayenne-server/src/main/java/org/apache/cayenne/velocity/VelocitySQLTemplateProcessor.java
index 6246821..2e6ab40 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/velocity/VelocitySQLTemplateProcessor.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/velocity/VelocitySQLTemplateProcessor.java
@@ -28,7 +28,7 @@ import java.util.Map;
 
 import org.apache.cayenne.CayenneRuntimeException;
 import org.apache.cayenne.access.jdbc.ColumnDescriptor;
-import org.apache.cayenne.access.jdbc.ParameterBinding;
+import org.apache.cayenne.access.jdbc.SQLParameterBinding;
 import org.apache.cayenne.access.jdbc.SQLStatement;
 import org.apache.cayenne.access.jdbc.SQLTemplateProcessor;
 import org.apache.cayenne.exp.ExpressionException;
@@ -152,7 +152,7 @@ public class VelocitySQLTemplateProcessor implements SQLTemplateProcessor {
 	}
 
 	SQLStatement processTemplate(String template, SimpleNode parsedTemplate, Map<String, Object> parameters) {
-		List<ParameterBinding> bindings = new ArrayList<ParameterBinding>();
+		List<SQLParameterBinding> bindings = new ArrayList<SQLParameterBinding>();
 		List<ColumnDescriptor> results = new ArrayList<ColumnDescriptor>();
 		parameters.put(BINDINGS_LIST_KEY, bindings);
 		parameters.put(RESULT_COLUMNS_LIST_KEY, results);
@@ -165,7 +165,7 @@ public class VelocitySQLTemplateProcessor implements SQLTemplateProcessor {
 			throw new CayenneRuntimeException("Error processing Velocity template", e);
 		}
 
-		ParameterBinding[] bindingsArray = new ParameterBinding[bindings.size()];
+		SQLParameterBinding[] bindingsArray = new SQLParameterBinding[bindings.size()];
 		bindings.toArray(bindingsArray);
 
 		ColumnDescriptor[] resultsArray = new ColumnDescriptor[results.size()];

http://git-wip-us.apache.org/repos/asf/cayenne/blob/81f4fb50/cayenne-server/src/test/java/org/apache/cayenne/access/jdbc/SQLStatementTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/jdbc/SQLStatementTest.java b/cayenne-server/src/test/java/org/apache/cayenne/access/jdbc/SQLStatementTest.java
index 88791b5..e0cc575 100644
--- a/cayenne-server/src/test/java/org/apache/cayenne/access/jdbc/SQLStatementTest.java
+++ b/cayenne-server/src/test/java/org/apache/cayenne/access/jdbc/SQLStatementTest.java
@@ -31,7 +31,7 @@ public class SQLStatementTest {
 
     @Test
     public void testConstructor() throws Exception {
-        ParameterBinding[] bindings = new ParameterBinding[0];
+        SQLParameterBinding[] bindings = new SQLParameterBinding[0];
         SQLStatement statement = new SQLStatement("abc", bindings);
         assertEquals("abc", statement.getSql());
         assertSame(bindings, statement.getBindings());

http://git-wip-us.apache.org/repos/asf/cayenne/blob/81f4fb50/cayenne-server/src/test/java/org/apache/cayenne/access/translator/batch/DefaultBatchTranslatorIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/translator/batch/DefaultBatchTranslatorIT.java b/cayenne-server/src/test/java/org/apache/cayenne/access/translator/batch/DefaultBatchTranslatorIT.java
index 439fb20..0fdc48b 100644
--- a/cayenne-server/src/test/java/org/apache/cayenne/access/translator/batch/DefaultBatchTranslatorIT.java
+++ b/cayenne-server/src/test/java/org/apache/cayenne/access/translator/batch/DefaultBatchTranslatorIT.java
@@ -19,6 +19,7 @@
 
 package org.apache.cayenne.access.translator.batch;
 
+import org.apache.cayenne.access.translator.ParameterBinding;
 import org.apache.cayenne.dba.DbAdapter;
 import org.apache.cayenne.dba.JdbcAdapter;
 import org.apache.cayenne.di.AdhocObjectFactory;
@@ -54,13 +55,13 @@ public class DefaultBatchTranslatorIT extends ServerCase {
             }
 
             @Override
-            protected BatchParameterBinding[] createBindings() {
-                return new BatchParameterBinding[0];
+            protected ParameterBinding[] createBindings() {
+                return new ParameterBinding[0];
             }
 
             @Override
-            protected BatchParameterBinding[] doUpdateBindings(BatchQueryRow row) {
-                return new BatchParameterBinding[0];
+            protected ParameterBinding[] doUpdateBindings(BatchQueryRow row) {
+                return new ParameterBinding[0];
             }
         };
 
@@ -80,13 +81,13 @@ public class DefaultBatchTranslatorIT extends ServerCase {
             }
 
             @Override
-            protected BatchParameterBinding[] createBindings() {
-                return new BatchParameterBinding[0];
+            protected ParameterBinding[] createBindings() {
+                return new ParameterBinding[0];
             }
 
             @Override
-            protected BatchParameterBinding[] doUpdateBindings(BatchQueryRow row) {
-                return new BatchParameterBinding[0];
+            protected ParameterBinding[] doUpdateBindings(BatchQueryRow row) {
+                return new ParameterBinding[0];
             }
         };
 
@@ -115,13 +116,13 @@ public class DefaultBatchTranslatorIT extends ServerCase {
             }
 
             @Override
-            protected BatchParameterBinding[] createBindings() {
-                return new BatchParameterBinding[0];
+            protected ParameterBinding[] createBindings() {
+                return new ParameterBinding[0];
             }
 
             @Override
-            protected BatchParameterBinding[] doUpdateBindings(BatchQueryRow row) {
-                return new BatchParameterBinding[0];
+            protected ParameterBinding[] doUpdateBindings(BatchQueryRow row) {
+                return new ParameterBinding[0];
             }
         };
 


Mime
View raw message