Repository: empire-db Updated Branches: refs/heads/master 0a8ae70fc -> 686ef2199
EMPIREDB-266 added DBQueryColumn factory method Project: http://git-wip-us.apache.org/repos/asf/empire-db/repo Commit: http://git-wip-us.apache.org/repos/asf/empire-db/commit/686ef219 Tree: http://git-wip-us.apache.org/repos/asf/empire-db/tree/686ef219 Diff: http://git-wip-us.apache.org/repos/asf/empire-db/diff/686ef219 Branch: refs/heads/master Commit: 686ef2199d767237df8e0917b99722095345c314 Parents: 0a8ae70 Author: Rainer Döbele <[email protected]> Authored: Sun Jan 7 12:39:34 2018 +0100 Committer: Rainer Döbele <[email protected]> Committed: Sun Jan 7 12:39:34 2018 +0100 ---------------------------------------------------------------------- .../main/java/org/apache/empire/db/DBQuery.java | 50 ++++++++++++-------- 1 file changed, 30 insertions(+), 20 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/empire-db/blob/686ef219/empire-db/src/main/java/org/apache/empire/db/DBQuery.java ---------------------------------------------------------------------- diff --git a/empire-db/src/main/java/org/apache/empire/db/DBQuery.java b/empire-db/src/main/java/org/apache/empire/db/DBQuery.java index 9e25b28..aaab557 100644 --- a/empire-db/src/main/java/org/apache/empire/db/DBQuery.java +++ b/empire-db/src/main/java/org/apache/empire/db/DBQuery.java @@ -83,7 +83,7 @@ public class DBQuery extends DBRowSet for (int i = 0; i < exprList.length; i++) { // Init Columns columns.add(exprList[i].getUpdateColumn()); - queryColumns[i] = new DBQueryColumn(this, exprList[i]); + queryColumns[i] = createQueryColumn(exprList[i]); } // Set the key Column this.keyColumns = keyColumns; @@ -150,18 +150,6 @@ public class DBQuery extends DBRowSet } /** - * returns the command from the underlying command expression or throws an exception - * @return the command used for this query - */ - private DBCommand getCommandFromExpression() - { - if (cmdExpr instanceof DBCommand) - return ((DBCommand)cmdExpr); - // not supported - throw new NotSupportedException(this, "getCommand"); - } - - /** * returns the underlying command expression * @return the command used for this query */ @@ -543,6 +531,18 @@ public class DBQuery extends DBRowSet } /** + * Deletes a record identified by its primary key from the database. + * + * @param keys array of primary key values + * @param conn a valid database connection + */ + @Override + public void deleteRecord(Object[] keys, Connection conn) + { + throw new NotImplementedException(this, "deleteRecord()"); + } + + /** * Adds join restrictions to the supplied command object. */ protected boolean addJoinRestriction(DBCommand upd, DBColumn updCol, DBColumn keyCol, DBColumn[] keyColumns, DBRecord rec) @@ -570,15 +570,25 @@ public class DBQuery extends DBRowSet } /** - * Deletes a record identified by its primary key from the database. - * - * @param keys array of primary key values - * @param conn a valid database connection + * returns the command from the underlying command expression or throws an exception + * @return the command used for this query */ - @Override - public void deleteRecord(Object[] keys, Connection conn) + protected DBCommand getCommandFromExpression() { - throw new NotImplementedException(this, "deleteRecord()"); + if (cmdExpr instanceof DBCommand) + return ((DBCommand)cmdExpr); + // not supported + throw new NotSupportedException(this, "getCommand"); + } + + /** + * factory method for column expressions in order to allow overrides + * @param expr + * @return the query column + */ + protected DBQueryColumn createQueryColumn(DBColumnExpr expr) + { + return new DBQueryColumn(this, expr); } } \ No newline at end of file
