Author: mikedd
Date: Mon Oct 29 08:48:31 2007
New Revision: 589696
URL: http://svn.apache.org/viewvc?rev=589696&view=rev
Log:
OPENJPA-423
Modified:
openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/TableJDBCSeq.java
openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/HSQLDictionary.java
Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/TableJDBCSeq.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/TableJDBCSeq.java?rev=589696&r1=589695&r2=589696&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/TableJDBCSeq.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/TableJDBCSeq.java
Mon Oct 29 08:48:31 2007
@@ -461,8 +461,9 @@
String tableName = resolveTableName(mapping, _seqColumn.getTable());
SQLBuffer tables = new SQLBuffer(dict).append(tableName);
- SQLBuffer select = dict.toSelect(sel, null, tables, where, null,
- null, null, false, dict.supportsSelectForUpdate, 0, Long.MAX_VALUE);
+ SQLBuffer select = dict.toSelect(sel, null, tables, where, null, null,
+ null, false, dict.supportsSelectForUpdate, 0, Long.MAX_VALUE,
+ false, true);
PreparedStatement stmnt = select.prepareStatement(conn);
ResultSet rs = null;
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=589696&r1=589695&r2=589696&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
Mon Oct 29 08:48:31 2007
@@ -2192,7 +2192,7 @@
/**
* Combine the given components into a SELECT statement.
*/
- private SQLBuffer toSelect(SQLBuffer selects, JDBCFetchConfiguration fetch,
+ 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,
@@ -2201,6 +2201,16 @@
group, having, order, distinct, start, end,
getForUpdateClause(fetch, forUpdate, null), subselect);
}
+
+ 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,
+ boolean subselect, boolean checkTableForUpdate) {
+ return toOperation(getSelectOperation(fetch), selects, from, where,
+ group, having, order, distinct, start, end,
+ getForUpdateClause(fetch, forUpdate, null), subselect, checkTableForUpdate);
+ }
/**
* Combine the given components into a SELECT statement.
@@ -2242,13 +2252,24 @@
/**
* Return the SQL for the given selecting operation.
*/
- protected SQLBuffer toOperation(String op, SQLBuffer selects,
+ public SQLBuffer toOperation(String op, SQLBuffer selects,
SQLBuffer from, SQLBuffer where, SQLBuffer group, SQLBuffer having,
SQLBuffer order, boolean distinct, long start, long end,
String forUpdateClause) {
return toOperation(op, selects, from, where, group, having, order,
distinct, start, end, forUpdateClause, false);
}
+
+ /**
+ * Return the SQL for the given selecting operation.
+ */
+ public SQLBuffer toOperation(String op, SQLBuffer selects,
+ SQLBuffer from, SQLBuffer where, SQLBuffer group, SQLBuffer having,
+ SQLBuffer order, boolean distinct, long start, long end,
+ String forUpdateClause, boolean subselect) {
+ return toOperation(op, selects, from, where, group, having, order,
+ distinct, start, end, forUpdateClause, subselect, false);
+ }
/**
* Return the SQL for the given selecting operation.
@@ -2256,7 +2277,7 @@
private SQLBuffer toOperation(String op, SQLBuffer selects,
SQLBuffer from, SQLBuffer where, SQLBuffer group, SQLBuffer having,
SQLBuffer order, boolean distinct, long start, long end,
- String forUpdateClause, boolean subselect) {
+ String forUpdateClause, boolean subselect, boolean checkTableForUpdate) {
SQLBuffer buf = new SQLBuffer(this);
buf.append(op);
@@ -2269,6 +2290,12 @@
appendSelectRange(buf, start, end, subselect);
buf.append(" ").append(selects).append(" FROM ").append(from);
+
+ if (checkTableForUpdate
+ && (StringUtils.isEmpty(forUpdateClause) && !StringUtils
+ .isEmpty(tableForUpdateClause))) {
+ buf.append(" ").append(tableForUpdateClause);
+ }
if (where != null && !where.isEmpty())
buf.append(" WHERE ").append(where);
Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/HSQLDictionary.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/HSQLDictionary.java?rev=589696&r1=589695&r2=589696&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/HSQLDictionary.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/HSQLDictionary.java
Mon Oct 29 08:48:31 2007
@@ -193,7 +193,7 @@
return buf.toString();
}
- protected SQLBuffer toOperation(String op, SQLBuffer selects,
+ public SQLBuffer toOperation(String op, SQLBuffer selects,
SQLBuffer from, SQLBuffer where, SQLBuffer group, SQLBuffer having,
SQLBuffer order, boolean distinct, long start, long end,
String forUpdateClause) {
|