OPENJPA-266, extensibility for platform specific version column

Passed TCK with Derby

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@554803 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
David J. Wisneski 2007-07-10 02:28:11 +00:00
parent 50332f053a
commit dfba4dff7d
2 changed files with 19 additions and 4 deletions

View File

@ -3839,4 +3839,14 @@ public class DBDictionary
this.bytes = bytes; this.bytes = bytes;
} }
} }
/**
* Return version column name
* @param column
* @param tableAlias : this is needed for platform specific version column
* @return
*/
public String getVersionColumn(Column column, String tableAlias) {
return column.toString();
}
} }

View File

@ -20,6 +20,7 @@ package org.apache.openjpa.jdbc.sql;
import java.io.InputStream; import java.io.InputStream;
import java.io.Reader; import java.io.Reader;
import java.lang.reflect.Method;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.BigInteger; import java.math.BigInteger;
import java.sql.Array; import java.sql.Array;
@ -756,7 +757,7 @@ public class RowImpl
hasVal = true; hasVal = true;
} }
appendWhere(buf); appendWhere(buf, dict);
return buf.toString(); return buf.toString();
} }
@ -797,14 +798,14 @@ public class RowImpl
StringBuffer buf = new StringBuffer(); StringBuffer buf = new StringBuffer();
buf.append("DELETE FROM "). buf.append("DELETE FROM ").
append(dict.getFullName(getTable(), false)); append(dict.getFullName(getTable(), false));
appendWhere(buf); appendWhere(buf, dict);
return buf.toString(); return buf.toString();
} }
/** /**
* Appends the where clause onto the given sql buffer. * Appends the where clause onto the given sql buffer.
*/ */
private void appendWhere(StringBuffer buf) { private void appendWhere(StringBuffer buf, DBDictionary dict) {
boolean hasWhere = false; boolean hasWhere = false;
for (int i = 0; i < _cols.length; i++) { for (int i = 0; i < _cols.length; i++) {
if (_vals[getWhereIndex(_cols[i])] == null) if (_vals[getWhereIndex(_cols[i])] == null)
@ -815,9 +816,13 @@ public class RowImpl
else else
buf.append(" AND "); buf.append(" AND ");
// Get platform specific version column name
if (_cols[i].getVersionStrategy() != null)
buf.append(dict.getVersionColumn(_cols[i], _cols[i]
.getTableName())).append(" = ?");
// sqlserver seems to have problems using null parameters in the // sqlserver seems to have problems using null parameters in the
// where clause // where clause
if (_vals[getWhereIndex(_cols[i])] == NULL) else if (_vals[getWhereIndex(_cols[i])] == NULL)
buf.append(_cols[i]).append(" IS NULL"); buf.append(_cols[i]).append(" IS NULL");
else if (_types[i] == RAW) else if (_types[i] == RAW)
buf.append(_cols[i]).append(" = ").append(_vals[i]); buf.append(_cols[i]).append(" = ").append(_vals[i]);