From d735ce2e22beab4ad707b53c2b6baa0554f7f37e Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Tue, 9 Oct 2012 12:36:50 -0500 Subject: [PATCH] IDEMPIERE-422 Complete Native Sequence feature / create the sequence if it doesn't exist on first usage, useful for native sequences not created on migration scripts --- org.adempiere.base/src/org/compiere/util/DB.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/org.adempiere.base/src/org/compiere/util/DB.java b/org.adempiere.base/src/org/compiere/util/DB.java index 8a8e06bd78..8f0ec3ada1 100644 --- a/org.adempiere.base/src/org/compiere/util/DB.java +++ b/org.adempiere.base/src/org/compiere/util/DB.java @@ -1867,6 +1867,11 @@ public final class DB if(SYSTEM_NATIVE_SEQUENCE && !adempiereSys) { int m_sequence_id = CConnection.get().getDatabase().getNextID(TableName+"_SQ"); + if (m_sequence_id == -1) { + // try to create the sequence and try again + MSequence.createTableSequence(Env.getCtx(), TableName, trxName, true); + m_sequence_id = CConnection.get().getDatabase().getNextID(TableName+"_SQ"); + } return m_sequence_id; }