From 121ac12f86a9770e066f5eee08ca4ce7bef296d3 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Tue, 23 Jul 2013 18:13:20 -0500 Subject: [PATCH] IDEMPIERE-1195 Native Sequences is reseting start on DB failures --- org.adempiere.base/src/org/compiere/model/GridTable.java | 1 + org.adempiere.base/src/org/compiere/model/MSequence.java | 4 ++-- .../src/org/compiere/db/DB_Oracle.java | 2 +- .../src/org/compiere/db/DB_PostgreSQL.java | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/org.adempiere.base/src/org/compiere/model/GridTable.java b/org.adempiere.base/src/org/compiere/model/GridTable.java index 79417d23ae..94632933a3 100644 --- a/org.adempiere.base/src/org/compiere/model/GridTable.java +++ b/org.adempiere.base/src/org/compiere/model/GridTable.java @@ -1501,6 +1501,7 @@ public class GridTable extends AbstractTableModel { log.log(Level.SEVERE, "Persistency Issue - " + m_tableName + ": " + e.getLocalizedMessage(), e); + log.saveError("Error", e.getLocalizedMessage()); return SAVE_ERROR; } } diff --git a/org.adempiere.base/src/org/compiere/model/MSequence.java b/org.adempiere.base/src/org/compiere/model/MSequence.java index 04c5da7aa7..7b6aacecc6 100644 --- a/org.adempiere.base/src/org/compiere/model/MSequence.java +++ b/org.adempiere.base/src/org/compiere/model/MSequence.java @@ -702,7 +702,7 @@ public class MSequence extends X_AD_Sequence if (tableID && SYSTEM_NATIVE_SEQUENCE) { - int next_id = DB.getSQLValue(trxName, "SELECT CurrentNext FROM AD_Sequence WHERE Name=? AND IsActive='Y' AND IsTableID='Y' AND IsAutoSequence='Y'", TableName); + int next_id = DB.getSQLValueEx(trxName, "SELECT CurrentNext FROM AD_Sequence WHERE Name=? AND IsActive='Y' AND IsTableID='Y' AND IsAutoSequence='Y'", TableName); if (next_id == -1) { MSequence seq = new MSequence (ctx, 0, trxName); @@ -793,7 +793,7 @@ public class MSequence extends X_AD_Sequence } catch (Exception e) { - s_log.log(Level.SEVERE, "get", e); + throw new DBException(e); } finally { diff --git a/org.compiere.db.oracle.provider/src/org/compiere/db/DB_Oracle.java b/org.compiere.db.oracle.provider/src/org/compiere/db/DB_Oracle.java index af18b339f0..e9b7391d3c 100644 --- a/org.compiere.db.oracle.provider/src/org/compiere/db/DB_Oracle.java +++ b/org.compiere.db.oracle.provider/src/org/compiere/db/DB_Oracle.java @@ -1239,7 +1239,7 @@ public class DB_Oracle implements AdempiereDatabase } public int getNextID(String Name) { - int m_sequence_id = DB.getSQLValue(null, "SELECT "+Name.toUpperCase()+".nextval FROM DUAL"); + int m_sequence_id = DB.getSQLValueEx(null, "SELECT "+Name.toUpperCase()+".nextval FROM DUAL"); return m_sequence_id; } diff --git a/org.compiere.db.postgresql.provider/src/org/compiere/db/DB_PostgreSQL.java b/org.compiere.db.postgresql.provider/src/org/compiere/db/DB_PostgreSQL.java index 9f9e39dbd8..cba4c51765 100755 --- a/org.compiere.db.postgresql.provider/src/org/compiere/db/DB_PostgreSQL.java +++ b/org.compiere.db.postgresql.provider/src/org/compiere/db/DB_PostgreSQL.java @@ -948,7 +948,7 @@ public class DB_PostgreSQL implements AdempiereDatabase public int getNextID(String name) { - int m_sequence_id = DB.getSQLValue(null, "SELECT nextval('"+name.toLowerCase()+"')"); + int m_sequence_id = DB.getSQLValueEx(null, "SELECT nextval('"+name.toLowerCase()+"')"); return m_sequence_id; }