From 39d8683b84c71e815326602b43244f3dd73a93f9 Mon Sep 17 00:00:00 2001 From: hns Date: Thu, 23 Oct 2003 14:35:02 +0000 Subject: [PATCH] Use Relation's additionalTables option when building queries. This activates the additionalTables feature contributed by Juerg Lehni. --- src/helma/objectmodel/db/NodeManager.java | 36 +++++++++++++++++++++-- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/src/helma/objectmodel/db/NodeManager.java b/src/helma/objectmodel/db/NodeManager.java index 2f4b01ff..a31537db 100644 --- a/src/helma/objectmodel/db/NodeManager.java +++ b/src/helma/objectmodel/db/NodeManager.java @@ -988,9 +988,15 @@ public final class NodeManager { try { String q = null; + StringBuffer tables = new StringBuffer(table); + + if (rel.additionalTables != null) { + tables.append(',').append(rel.additionalTables); + } + StringBuffer b = new StringBuffer("SELECT ").append(table).append('.') .append(idfield).append(" FROM ") - .append(table); + .append(tables); if (home.getSubnodeRelation() != null) { // subnode relation was explicitly set @@ -1085,6 +1091,10 @@ public final class NodeManager { Relation[] joins = dbm.getJoins(); StringBuffer q = dbm.getSelect(); + if (rel.additionalTables != null) { + q.append(',').append(rel.additionalTables); + } + try { if (home.getSubnodeRelation() != null) { q.append(home.getSubnodeRelation()); @@ -1163,6 +1173,10 @@ public final class NodeManager { Relation[] joins = dbm.getJoins(); StringBuffer q = dbm.getSelect(); + if (rel.additionalTables != null) { + q.append(',').append(rel.additionalTables); + } + try { String idfield = (rel.groupby != null) ? rel.groupby : dbm.getIDField(); boolean needsQuotes = dbm.needsQuotes(idfield); @@ -1335,7 +1349,13 @@ public final class NodeManager { try { String q = null; - StringBuffer b = new StringBuffer("SELECT count(*) FROM ").append(table); + StringBuffer tables = new StringBuffer(table); + + if (rel.additionalTables != null) { + tables.append(',').append(rel.additionalTables); + } + + StringBuffer b = new StringBuffer("SELECT count(*) FROM ").append(tables); if (home.getSubnodeRelation() != null) { // use the manually set subnoderelation of the home node @@ -1398,10 +1418,16 @@ public final class NodeManager { Statement stmt = null; + StringBuffer tables = new StringBuffer(table); + + if (rel.additionalTables != null) { + tables.append(',').append(rel.additionalTables); + } + try { StringBuffer q = new StringBuffer("SELECT ").append(namefield) .append(" FROM ") - .append(table); + .append(tables); if (home.getSubnodeRelation() != null) { q.append(" ").append(home.getSubnodeRelation()); @@ -1558,6 +1584,10 @@ public final class NodeManager { Relation[] joins = dbm.getJoins(); StringBuffer q = dbm.getSelect(); + if (rel.additionalTables != null) { + q.append(',').append(rel.additionalTables); + } + if (home.getSubnodeRelation() != null && !rel.isComplexReference()) { // combine our key with the constraints in the manually set subnode relation q.append("WHERE ");