OPENJPA-423

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@589696 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Dick 2007-10-29 15:48:31 +00:00
parent 1f92ab5842
commit 80d2c39020
3 changed files with 34 additions and 6 deletions

View File

@ -461,8 +461,9 @@ public class TableJDBCSeq
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;

View File

@ -2192,7 +2192,7 @@ public class DBDictionary
/**
* 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,
@ -2202,6 +2202,16 @@ public class DBDictionary
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,7 +2252,7 @@ public class DBDictionary
/**
* 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) {
@ -2253,10 +2263,21 @@ public class DBDictionary
/**
* Return the SQL for the given selecting operation.
*/
private 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, 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.
*/
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, boolean checkTableForUpdate) {
SQLBuffer buf = new SQLBuffer(this);
buf.append(op);
@ -2270,6 +2291,12 @@ public class DBDictionary
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);
if (group != null && !group.isEmpty())

View File

@ -193,7 +193,7 @@ public class HSQLDictionary
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) {