mirror of https://github.com/apache/openjpa.git
OPENJPA-2131 - Commit contribution by Zilin Chen.
git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@1309495 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
8e445e03a1
commit
06742412b3
|
@ -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));
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
4
pom.xml
4
pom.xml
|
@ -522,12 +522,12 @@
|
|||
<dependency>
|
||||
<groupId>javax.xml.bind</groupId>
|
||||
<artifactId>jaxb-api</artifactId>
|
||||
<version>2.0</version>
|
||||
<version>2.2.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.xml.bind</groupId>
|
||||
<artifactId>jaxb-impl</artifactId>
|
||||
<version>2.0.5</version>
|
||||
<version>2.2.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>hsqldb</groupId>
|
||||
|
|
Loading…
Reference in New Issue