diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/OracleDictionary.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/OracleDictionary.java
index 36568040e..ec05e201e 100644
--- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/OracleDictionary.java
+++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/OracleDictionary.java
@@ -362,10 +362,12 @@ public class OracleDictionary
for (Iterator itr = aliases.iterator(); itr.hasNext(); i++) {
alias = itr.next();
String asString = null;
- if (alias instanceof SQLBuffer)
+ if (alias instanceof SQLBuffer) {
asString = ((SQLBuffer) alias).getSQL();
- else
+ selectSQL.appendParamOnly((SQLBuffer) alias);
+ } else {
asString = alias.toString();
+ }
selectSQL.append(asString);
if (asString.indexOf(" AS ") == -1)
selectSQL.append(" AS c").append(String.valueOf(i));
diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SQLBuffer.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SQLBuffer.java
index fc474750d..345877ffc 100644
--- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SQLBuffer.java
+++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SQLBuffer.java
@@ -102,16 +102,23 @@ public final class SQLBuffer
* Append all SQL and parameters of the given buffer.
*/
public SQLBuffer append(SQLBuffer buf) {
- append(buf, _sql.length(), (_params == null) ? 0 : _params.size(),
- true);
+ append(buf, _sql.length(), (_params == null) ? 0 : _params.size(), true, false);
return this;
}
/**
- * Append all SQL and parameters of the given buffer at the given positions.
+ * Append parameters only if the given buffer at the given positions.
+ */
+ public SQLBuffer appendParamOnly(SQLBuffer buf) {
+ append(buf, _sql.length(), (_params == null) ? 0 : _params.size(), true, true);
+ return this;
+ }
+
+ /**
+ * Append parameters and/or SQL of the given buffer at the given positions.
*/
private void append(SQLBuffer buf, int sqlIndex, int paramIndex,
- boolean subsels) {
+ boolean subsels, boolean paramOnly) {
if (subsels) {
// only allow appending of buffers with subselects, not insertion
if (_subsels != null && !_subsels.isEmpty()
@@ -128,10 +135,12 @@ public final class SQLBuffer
}
}
- if (sqlIndex == _sql.length())
- _sql.append(buf._sql.toString());
- else
- _sql.insert(sqlIndex, buf._sql.toString());
+ if (!paramOnly) {
+ if (sqlIndex == _sql.length())
+ _sql.append(buf._sql.toString());
+ else
+ _sql.insert(sqlIndex, buf._sql.toString());
+ }
if (buf._params != null) {
if (_params == null)
@@ -404,7 +413,7 @@ public final class SQLBuffer
else
buf = sub.select.toSelect(false, sub.fetch);
buf.resolveSubselects();
- append(buf, sub.sqlIndex, sub.paramIndex, false);
+ append(buf, sub.sqlIndex, sub.paramIndex, false, false);
}
_subsels.clear();
}
diff --git a/pom.xml b/pom.xml
index bf8030d1a..6f7f32214 100644
--- a/pom.xml
+++ b/pom.xml
@@ -522,12 +522,12 @@
javax.xml.bind
jaxb-api
- 2.0
+ 2.2.1
com.sun.xml.bind
jaxb-impl
- 2.0.5
+ 2.2.1
hsqldb