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

This commit is contained in:
Carlos Ruiz 2012-10-09 12:36:50 -05:00
parent 83a7f121c3
commit d735ce2e22
1 changed files with 5 additions and 0 deletions

View File

@ -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;
}