You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openjpa.apache.org by fa...@apache.org on 2007/09/12 23:08:54 UTC
svn commit: r575079 - in
/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql:
DB2Dictionary.java DBDictionary.java
Author: fancy
Date: Wed Sep 12 14:08:53 2007
New Revision: 575079
URL: http://svn.apache.org/viewvc?rev=575079&view=rev
Log:
OPENJPA-360 FOR UPDATE clause incorrectly generated
remove transient variable
Modified:
openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java?rev=575079&r1=575078&r2=575079&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java (original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java Wed Sep 12 14:08:53 2007
@@ -313,12 +313,12 @@
* updateClause and isolationLevel hints
*/
protected String getForUpdateClause(JDBCFetchConfiguration fetch,
- boolean isForUpdate) {
+ boolean isForUpdate, Select sel) {
int isolationLevel;
// For db2UDBV81OrEarlier and db2ISeriesV5R3OrEarlier:
// "optimize for" clause appears before "for update" clause.
StringBuffer forUpdateString = new StringBuffer(
- getOptimizeClause(fetch));
+ getOptimizeClause(sel));
try {
// Determine the isolationLevel; the fetch
// configuration data overrides the persistence.xml value
@@ -464,7 +464,7 @@
}
}
- protected String getOptimizeClause(JDBCFetchConfiguration fetch) {
+ protected String getOptimizeClause(Select sel) {
if (sel != null && sel.getExpectedResultCount() > 0) {
StringBuffer buf = new StringBuffer();
buf.append(" ").append(optimizeClause).append(" ")
Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java?rev=575079&r1=575078&r2=575079&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java (original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java Wed Sep 12 14:08:53 2007
@@ -60,7 +60,6 @@
import java.util.Locale;
import java.util.Map;
import java.util.Set;
-import java.util.HashMap;
import javax.sql.DataSource;
import org.apache.commons.lang.StringUtils;
@@ -70,8 +69,6 @@
import org.apache.openjpa.jdbc.kernel.exps.ExpContext;
import org.apache.openjpa.jdbc.kernel.exps.ExpState;
import org.apache.openjpa.jdbc.kernel.exps.FilterValue;
-import org.apache.openjpa.jdbc.kernel.exps.Lit;
-import org.apache.openjpa.jdbc.kernel.exps.Param;
import org.apache.openjpa.jdbc.kernel.exps.Val;
import org.apache.openjpa.jdbc.meta.ClassMapping;
import org.apache.openjpa.jdbc.meta.FieldMapping;
@@ -88,7 +85,6 @@
import org.apache.openjpa.jdbc.schema.Table;
import org.apache.openjpa.jdbc.schema.Unique;
import org.apache.openjpa.kernel.Filters;
-import org.apache.openjpa.kernel.exps.Path;
import org.apache.openjpa.lib.conf.Configurable;
import org.apache.openjpa.lib.conf.Configuration;
import org.apache.openjpa.lib.jdbc.ConnectionDecorator;
@@ -325,7 +321,6 @@
private Method _setBytes = null;
private Method _setString = null;
private Method _setCharStream = null;
- protected transient Select sel = null;
public DBDictionary() {
fixedSizeTypeNameSet.addAll(Arrays.asList(new String[]{
@@ -1989,7 +1984,6 @@
*/
public SQLBuffer toSelect(Select sel, boolean forUpdate,
JDBCFetchConfiguration fetch) {
- this.sel = sel;
sel.addJoinClassConditions();
boolean update = forUpdate && sel.getFromSelect() == null;
SQLBuffer select = getSelects(sel, false, update);
@@ -2004,7 +1998,7 @@
SQLBuffer where = getWhere(sel, update);
return toSelect(select, fetch, from, where, sel.getGrouping(),
sel.getHaving(), ordering, sel.isDistinct(), forUpdate,
- sel.getStartIndex(), sel.getEndIndex());
+ sel.getStartIndex(), sel.getEndIndex(), sel);
}
/**
@@ -2192,7 +2186,20 @@
boolean distinct, boolean forUpdate, long start, long end) {
return toOperation(getSelectOperation(fetch), selects, from, where,
group, having, order, distinct, start, end,
- getForUpdateClause(fetch, forUpdate));
+ getForUpdateClause(fetch, forUpdate, null));
+ }
+
+ /**
+ * Combine the given components into a SELECT statement.
+ */
+ public SQLBuffer toSelect(SQLBuffer selects, JDBCFetchConfiguration fetch,
+ SQLBuffer from, SQLBuffer where, SQLBuffer group,
+ SQLBuffer having, SQLBuffer order,
+ boolean distinct, boolean forUpdate, long start, long end
+ , Select sel) {
+ return toOperation(getSelectOperation(fetch), selects, from, where,
+ group, having, order, distinct, start, end,
+ getForUpdateClause(fetch, forUpdate, sel));
}
/**
@@ -2200,7 +2207,7 @@
* updateClause and isolationLevel hints
*/
protected String getForUpdateClause(JDBCFetchConfiguration fetch,
- boolean isForUpdate) {
+ boolean isForUpdate, Select sel) {
if (fetch != null && fetch.getIsolation() != -1) {
throw new InvalidStateException(_loc.get(
"isolation-level-config-not-supported", getClass().getName()));