IDEMPIERE-3870 PackIn issue with transactions
This commit is contained in:
parent
3456ab5b6b
commit
02009bc22d
|
@ -93,7 +93,7 @@ public class GenericPO extends PO {
|
||||||
PropertiesWrapper wrapper = (PropertiesWrapper)ctx;
|
PropertiesWrapper wrapper = (PropertiesWrapper)ctx;
|
||||||
p_ctx = wrapper.source;
|
p_ctx = wrapper.source;
|
||||||
tableName = wrapper.tableName;
|
tableName = wrapper.tableName;
|
||||||
tableID = MTable.getTable_ID(tableName);
|
tableID = MTable.getTable_ID(tableName, this.get_TrxName());
|
||||||
// log.info("Table_ID: "+Table_ID);
|
// log.info("Table_ID: "+Table_ID);
|
||||||
POInfo poi = POInfo.getPOInfo(ctx, tableID, this.get_TrxName());
|
POInfo poi = POInfo.getPOInfo(ctx, tableID, this.get_TrxName());
|
||||||
return poi;
|
return poi;
|
||||||
|
|
|
@ -206,6 +206,13 @@ public interface AdempiereDatabase
|
||||||
public String TO_NUMBER (BigDecimal number, int displayType);
|
public String TO_NUMBER (BigDecimal number, int displayType);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return next sequence this Sequence
|
||||||
|
* @param Sequence Name
|
||||||
|
* @param Transaction
|
||||||
|
*/
|
||||||
|
public int getNextID(String Name, String trxName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return next sequence this Sequence
|
* Return next sequence this Sequence
|
||||||
* @param Sequence Name
|
* @param Sequence Name
|
||||||
|
|
|
@ -58,7 +58,7 @@ public class MTable extends X_AD_Table
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 7527235342324308477L;
|
private static final long serialVersionUID = 4974471096496488963L;
|
||||||
|
|
||||||
public final static int MAX_OFFICIAL_ID = 999999;
|
public final static int MAX_OFFICIAL_ID = 999999;
|
||||||
|
|
||||||
|
@ -614,19 +614,22 @@ public class MTable extends X_AD_Table
|
||||||
} // getSQLCreate
|
} // getSQLCreate
|
||||||
|
|
||||||
// globalqss
|
// globalqss
|
||||||
|
public static int getTable_ID(String tableName) {
|
||||||
|
return getTable_ID(tableName, null);
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Grant independence to GenerateModel from AD_Table_ID
|
* Grant independence to GenerateModel from AD_Table_ID
|
||||||
* @param String tableName
|
* @param String tableName
|
||||||
* @return int retValue
|
* @return int retValue
|
||||||
*/
|
*/
|
||||||
public static int getTable_ID(String tableName) {
|
public static int getTable_ID(String tableName, String trxName) {
|
||||||
int retValue = 0;
|
int retValue = 0;
|
||||||
String SQL = "SELECT AD_Table_ID FROM AD_Table WHERE tablename = ?";
|
String SQL = "SELECT AD_Table_ID FROM AD_Table WHERE tablename = ?";
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement(SQL, null);
|
pstmt = DB.prepareStatement(SQL, trxName);
|
||||||
pstmt.setString(1, tableName);
|
pstmt.setString(1, tableName);
|
||||||
rs = pstmt.executeQuery();
|
rs = pstmt.executeQuery();
|
||||||
if (rs.next())
|
if (rs.next())
|
||||||
|
|
|
@ -1829,11 +1829,11 @@ public final class DB
|
||||||
|
|
||||||
if(SYSTEM_NATIVE_SEQUENCE && !adempiereSys)
|
if(SYSTEM_NATIVE_SEQUENCE && !adempiereSys)
|
||||||
{
|
{
|
||||||
int m_sequence_id = CConnection.get().getDatabase().getNextID(TableName+"_SQ");
|
int m_sequence_id = CConnection.get().getDatabase().getNextID(TableName+"_SQ", trxName);
|
||||||
if (m_sequence_id == -1) {
|
if (m_sequence_id == -1) {
|
||||||
// try to create the sequence and try again
|
// try to create the sequence and try again
|
||||||
MSequence.createTableSequence(Env.getCtx(), TableName, trxName, true);
|
MSequence.createTableSequence(Env.getCtx(), TableName, trxName, true);
|
||||||
m_sequence_id = CConnection.get().getDatabase().getNextID(TableName+"_SQ");
|
m_sequence_id = CConnection.get().getDatabase().getNextID(TableName+"_SQ", trxName);
|
||||||
}
|
}
|
||||||
return m_sequence_id;
|
return m_sequence_id;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1248,8 +1248,12 @@ public class DB_Oracle implements AdempiereDatabase
|
||||||
return m_convert;
|
return m_convert;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getNextID(String Name) {
|
public int getNextID(String name) {
|
||||||
int m_sequence_id = DB.getSQLValueEx(null, "SELECT "+Name.toUpperCase()+".nextval FROM DUAL");
|
return getNextID(name, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getNextID(String name, String trxName) {
|
||||||
|
int m_sequence_id = DB.getSQLValueEx(trxName, "SELECT "+name.toUpperCase()+".nextval FROM DUAL");
|
||||||
return m_sequence_id;
|
return m_sequence_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -966,8 +966,11 @@ public class DB_PostgreSQL implements AdempiereDatabase
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getNextID(String name) {
|
public int getNextID(String name) {
|
||||||
|
return getNextID(name, null);
|
||||||
|
}
|
||||||
|
|
||||||
int m_sequence_id = DB.getSQLValueEx(null, "SELECT nextval('"+name.toLowerCase()+"')");
|
public int getNextID(String name, String trxName) {
|
||||||
|
int m_sequence_id = DB.getSQLValueEx(trxName, "SELECT nextval('"+name.toLowerCase()+"')");
|
||||||
return m_sequence_id;
|
return m_sequence_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue