IDEMPIERE-2664 DB Extensibility issues / calling convert for direct prepareStatement

This commit is contained in:
Carlos Ruiz 2015-06-17 12:32:06 -05:00
parent 7ae9056c5b
commit 30f76d2c74
6 changed files with 31 additions and 15 deletions

View File

@ -1 +1 @@
java -Xms128m -Xmx512m -classpath "../../../tools/lib/ant.jar;../../../tools/lib/ant-launcher.jar;../../../tools/lib/ant-swing.jar;../../../tools/lib/ant-commons-net.jar;../../../tools/lib/commons-net.jar" -Dant.home="." org.apache.tools.ant.Main $* java -Xms128m -Xmx512m -classpath "../../../targetPlatform/plugins/org.apache.ant_1.7.1.v20100518-1145/lib/ant.jar:../../../targetPlatform/plugins/org.apache.ant_1.7.1.v20100518-1145/lib/ant-launcher.jar:../../../targetPlatform/plugins/org.apache.ant_1.7.1.v20100518-1145/lib/ant-swing.jar:../../../targetPlatform/plugins/org.apache.ant_1.7.1.v20100518-1145/lib/ant-commons-net.jar" -Dant.home="." org.apache.tools.ant.Main $*

View File

@ -320,7 +320,8 @@ public class ColumnEncryption extends SvrProcess {
ResultSet rs = null; ResultSet rs = null;
try { try {
selectStmt = m_conn.prepareStatement(selectSql.toString(), String selectSqlStr = DB.getDatabase().convertStatement(selectSql.toString());
selectStmt = m_conn.prepareStatement(selectSqlStr,
ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE); ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
updateStmt = m_conn.prepareStatement(updateSql.toString()); updateStmt = m_conn.prepareStatement(updateSql.toString());
@ -397,7 +398,8 @@ public class ColumnEncryption extends SvrProcess {
ResultSet rs = null; ResultSet rs = null;
try { try {
selectStmt = m_conn.prepareStatement(selectSql.toString(), String selectSqlStr = DB.getDatabase().convertStatement(selectSql.toString());
selectStmt = m_conn.prepareStatement(selectSqlStr,
ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE); ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
updateStmt = m_conn.prepareStatement(updateSql.toString()); updateStmt = m_conn.prepareStatement(updateSql.toString());
@ -460,10 +462,7 @@ public class ColumnEncryption extends SvrProcess {
int rowsEffected = -1; int rowsEffected = -1;
// Select SQL // Select SQL
StringBuilder selectSql = new StringBuilder(); String selectSql = "SELECT FieldLength FROM AD_Column WHERE AD_Column_ID=?";
selectSql.append("SELECT FieldLength");
selectSql.append(" FROM AD_Column");
selectSql.append(" WHERE AD_Column_ID=?");
// Alter SQL // Alter SQL
StringBuilder alterSql = new StringBuilder(); StringBuilder alterSql = new StringBuilder();
@ -482,7 +481,8 @@ public class ColumnEncryption extends SvrProcess {
ResultSet rs = null; ResultSet rs = null;
try { try {
selectStmt = m_conn.prepareStatement(selectSql.toString(), selectSql = DB.getDatabase().convertStatement(selectSql);
selectStmt = m_conn.prepareStatement(selectSql,
ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE); ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
selectStmt.setInt(1, columnID); selectStmt.setInt(1, columnID);

View File

@ -541,6 +541,7 @@ public class ReplicationLocal extends SvrProcess
// //
try try
{ {
sql = DB.getDatabase().convertStatement(sql);
pstmt = conn.prepareStatement(sql, pstmt = conn.prepareStatement(sql,
ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
// Set Parameters // Set Parameters

View File

@ -125,6 +125,8 @@ public class MSequence extends X_AD_Sequence
+ " AND IsActive='Y' AND IsTableID='Y' AND IsAutoSequence='Y' "; + " AND IsActive='Y' AND IsTableID='Y' AND IsAutoSequence='Y' ";
} }
if (!DB.isOracle() && !DB.isPostgreSQL())
selectSQL = DB.getDatabase().convertStatement(selectSQL);
Connection conn = null; Connection conn = null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
@ -221,12 +223,16 @@ public class MSequence extends X_AD_Sequence
{ {
int incrementNo = rs.getInt(3); int incrementNo = rs.getInt(3);
if (adempiereSys) { if (adempiereSys) {
updateSQL = conn String updateCmd = "UPDATE AD_Sequence SET CurrentNextSys=CurrentNextSys+? WHERE AD_Sequence_ID=?";
.prepareStatement("UPDATE AD_Sequence SET CurrentNextSys = CurrentNextSys + ? WHERE AD_Sequence_ID = ?"); if (!DB.isOracle() && !DB.isPostgreSQL())
updateCmd = DB.getDatabase().convertStatement(updateCmd);
updateSQL = conn.prepareStatement(updateCmd);
retValue = rs.getInt(2); retValue = rs.getInt(2);
} else { } else {
updateSQL = conn String updateCmd = "UPDATE AD_Sequence SET CurrentNext=CurrentNext+? WHERE AD_Sequence_ID=?";
.prepareStatement("UPDATE AD_Sequence SET CurrentNext = CurrentNext + ? WHERE AD_Sequence_ID = ?"); if (!DB.isOracle() && !DB.isPostgreSQL())
updateCmd = DB.getDatabase().convertStatement(updateCmd);
updateSQL = conn.prepareStatement(updateCmd);
retValue = rs.getInt(1); retValue = rs.getInt(1);
} }
updateSQL.setInt(1, incrementNo); updateSQL.setInt(1, incrementNo);
@ -367,6 +373,8 @@ public class MSequence extends X_AD_Sequence
selectSQL = selectSQL + " FOR UPDATE OF s"; selectSQL = selectSQL + " FOR UPDATE OF s";
} }
} }
if (!DB.isOracle() && !DB.isPostgreSQL())
selectSQL = DB.getDatabase().convertStatement(selectSQL);
Connection conn = null; Connection conn = null;
Trx trx = trxName == null ? null : Trx.get(trxName, true); Trx trx = trxName == null ? null : Trx.get(trxName, true);
// //
@ -439,7 +447,10 @@ public class MSequence extends X_AD_Sequence
try try
{ {
if (adempiereSys) { if (adempiereSys) {
updateSQL = conn.prepareStatement("UPDATE AD_Sequence SET CurrentNextSys = CurrentNextSys + ? WHERE AD_Sequence_ID = ?"); String updateCmd = "UPDATE AD_Sequence SET CurrentNextSys = CurrentNextSys + ? WHERE AD_Sequence_ID = ?";
if (!DB.isOracle() && !DB.isPostgreSQL())
updateCmd = DB.getDatabase().convertStatement(updateCmd);
updateSQL = conn.prepareStatement(updateCmd);
next = rs.getInt(2); next = rs.getInt(2);
} else { } else {
String sql; String sql;
@ -447,6 +458,8 @@ public class MSequence extends X_AD_Sequence
sql = "UPDATE AD_Sequence_No SET CurrentNext = CurrentNext + ? WHERE AD_Sequence_ID=? AND CalendarYearMonth=? AND AD_Org_ID=?"; sql = "UPDATE AD_Sequence_No SET CurrentNext = CurrentNext + ? WHERE AD_Sequence_ID=? AND CalendarYearMonth=? AND AD_Org_ID=?";
else else
sql = "UPDATE AD_Sequence SET CurrentNext = CurrentNext + ? WHERE AD_Sequence_ID=?"; sql = "UPDATE AD_Sequence SET CurrentNext = CurrentNext + ? WHERE AD_Sequence_ID=?";
if (!DB.isOracle() && !DB.isPostgreSQL())
sql = DB.getDatabase().convertStatement(sql);
updateSQL = conn.prepareStatement(sql); updateSQL = conn.prepareStatement(sql);
next = rs.getInt(1); next = rs.getInt(1);
} }

View File

@ -115,6 +115,8 @@ public class PO_LOB implements Serializable
.append(m_tableName) .append(m_tableName)
.append(" SET ").append(m_columnName) .append(" SET ").append(m_columnName)
.append("=? WHERE ").append(m_whereClause); .append("=? WHERE ").append(m_whereClause);
if (!DB.isPostgreSQL() && !DB.isOracle())
sql = new StringBuffer(DB.getDatabase().convertStatement(sql.toString()));
// //
if (log.isLoggable(Level.FINE)) log.fine("[" + trxName + "] - Local - " + m_value); if (log.isLoggable(Level.FINE)) log.fine("[" + trxName + "] - Local - " + m_value);

View File

@ -409,12 +409,12 @@ public class InfoGeneralPanel extends InfoPanel implements EventListener<Event>
{ {
if (Env.isBaseLanguage(Env.getCtx(), "AD_Ref_List")) if (Env.isBaseLanguage(Env.getCtx(), "AD_Ref_List"))
colSql = new StringBuffer("(SELECT l.Name FROM AD_Ref_List l WHERE l.AD_Reference_ID=") colSql = new StringBuffer("(SELECT l.Name FROM AD_Ref_List l WHERE l.AD_Reference_ID=")
.append(AD_Reference_Value_ID).append(" AND l.Value=").append(columnSql) .append(AD_Reference_Value_ID).append(" AND l.Value=").append(tableName).append(".").append(columnSql)
.append(") AS ").append(columnName); .append(") AS ").append(columnName);
else else
colSql = new StringBuffer("(SELECT t.Name FROM AD_Ref_List l, AD_Ref_List_Trl t " colSql = new StringBuffer("(SELECT t.Name FROM AD_Ref_List l, AD_Ref_List_Trl t "
+ "WHERE l.AD_Ref_List_ID=t.AD_Ref_List_ID AND l.AD_Reference_ID=") + "WHERE l.AD_Ref_List_ID=t.AD_Ref_List_ID AND l.AD_Reference_ID=")
.append(AD_Reference_Value_ID).append(" AND l.Value=").append(columnSql) .append(AD_Reference_Value_ID).append(" AND l.Value=").append(tableName).append(".").append(columnSql)
.append(" AND t.AD_Language='").append(Env.getAD_Language(Env.getCtx())) .append(" AND t.AD_Language='").append(Env.getAD_Language(Env.getCtx()))
.append("') AS ").append(columnName); .append("') AS ").append(columnName);
colClass = String.class; colClass = String.class;