[ 1854455 ] PO.initPO doesn't have transaction support
This commit is contained in:
parent
52548605ec
commit
f61dd20986
|
@ -594,7 +594,7 @@ public class MTable extends X_AD_Table
|
|||
return null;
|
||||
//
|
||||
PO po = null;
|
||||
POInfo info = POInfo.getPOInfo(getCtx(), getAD_Table_ID());
|
||||
POInfo info = POInfo.getPOInfo(getCtx(), getAD_Table_ID(), trxName);
|
||||
if (info == null) return null;
|
||||
StringBuffer sqlBuffer = info.buildSelect();
|
||||
sqlBuffer.append(" WHERE ").append(whereClause);
|
||||
|
|
|
@ -115,6 +115,8 @@ public abstract class PO
|
|||
if (ctx == null)
|
||||
throw new IllegalArgumentException ("No Context");
|
||||
p_ctx = ctx;
|
||||
m_trxName = trxName;
|
||||
|
||||
p_info = initPO(ctx);
|
||||
if (p_info == null || p_info.getTableName() == null)
|
||||
throw new IllegalArgumentException ("Invalid PO Info - " + p_info);
|
||||
|
@ -122,7 +124,7 @@ public abstract class PO
|
|||
int size = p_info.getColumnCount();
|
||||
m_oldValues = new Object[size];
|
||||
m_newValues = new Object[size];
|
||||
m_trxName = trxName;
|
||||
|
||||
if (rs != null)
|
||||
load(rs); // will not have virtual columns
|
||||
else
|
||||
|
|
|
@ -42,6 +42,18 @@ public class POInfo implements Serializable
|
|||
* @return POInfo
|
||||
*/
|
||||
public static POInfo getPOInfo (Properties ctx, int AD_Table_ID)
|
||||
{
|
||||
return getPOInfo(ctx, AD_Table_ID, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* POInfo Factory
|
||||
* @param ctx context
|
||||
* @param AD_Table_ID AD_Table_ID
|
||||
* @param trxName Transaction name
|
||||
* @return POInfo
|
||||
*/
|
||||
public static POInfo getPOInfo (Properties ctx, int AD_Table_ID, String trxName)
|
||||
{
|
||||
Integer key = new Integer(AD_Table_ID);
|
||||
POInfo retValue = (POInfo)s_cache.get(key);
|
||||
|
@ -67,11 +79,23 @@ public class POInfo implements Serializable
|
|||
* @param baseLanguageOnly get in base language
|
||||
*/
|
||||
private POInfo (Properties ctx, int AD_Table_ID, boolean baseLanguageOnly)
|
||||
{
|
||||
this(ctx, AD_Table_ID, baseLanguageOnly, null);
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* Create Persistent Info
|
||||
* @param ctx context
|
||||
* @param AD_Table_ID AD_ Table_ID
|
||||
* @param baseLanguageOnly get in base language
|
||||
* @param trxName transaction name
|
||||
*/
|
||||
private POInfo (Properties ctx, int AD_Table_ID, boolean baseLanguageOnly, String trxName)
|
||||
{
|
||||
m_ctx = ctx;
|
||||
m_AD_Table_ID = AD_Table_ID;
|
||||
boolean baseLanguage = baseLanguageOnly ? true : Env.isBaseLanguage(m_ctx, "AD_Table");
|
||||
loadInfo (baseLanguage);
|
||||
loadInfo (baseLanguage, trxName);
|
||||
} // PInfo
|
||||
|
||||
/** Context */
|
||||
|
@ -91,8 +115,9 @@ public class POInfo implements Serializable
|
|||
/**
|
||||
* Load Table/Column Info
|
||||
* @param baseLanguage in English
|
||||
* @param trxName
|
||||
*/
|
||||
private void loadInfo (boolean baseLanguage)
|
||||
private void loadInfo (boolean baseLanguage, String trxName)
|
||||
{
|
||||
ArrayList<POInfoColumn> list = new ArrayList<POInfoColumn>(15);
|
||||
StringBuffer sql = new StringBuffer();
|
||||
|
@ -116,9 +141,10 @@ public class POInfo implements Serializable
|
|||
if (!baseLanguage)
|
||||
sql.append(" AND e.AD_Language='").append(Env.getAD_Language(m_ctx)).append("'");
|
||||
//
|
||||
PreparedStatement pstmt = null;
|
||||
try
|
||||
{
|
||||
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null);
|
||||
pstmt = DB.prepareStatement(sql.toString(), trxName);
|
||||
pstmt.setInt(1, m_AD_Table_ID);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
while (rs.next())
|
||||
|
@ -159,12 +185,22 @@ public class POInfo implements Serializable
|
|||
list.add(col);
|
||||
}
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
CLogger.get().log(Level.SEVERE, sql.toString(), e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if( pstmt != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
pstmt.close();
|
||||
}
|
||||
catch (SQLException e) {}
|
||||
}
|
||||
}
|
||||
// convert to array
|
||||
m_columns = new POInfoColumn[list.size()];
|
||||
list.toArray(m_columns);
|
||||
|
|
|
@ -94,7 +94,7 @@ public class POIterator implements Iterator<PO> {
|
|||
} else {
|
||||
if (keyWhereClause == null) {
|
||||
String[] keys = table.getKeyColumns();
|
||||
POInfo info = POInfo.getPOInfo(Env.getCtx(), table.getAD_Table_ID());
|
||||
POInfo info = POInfo.getPOInfo(Env.getCtx(), table.getAD_Table_ID(), trxName);
|
||||
if (info == null) return null;
|
||||
StringBuffer sqlBuffer = info.buildSelect();
|
||||
sqlBuffer.append(" WHERE ");
|
||||
|
|
|
@ -89,7 +89,7 @@ public class Query {
|
|||
public List<PO> list() throws SQLException {
|
||||
List<PO> list = new ArrayList<PO>();
|
||||
|
||||
POInfo info = POInfo.getPOInfo(Env.getCtx(), table.getAD_Table_ID());
|
||||
POInfo info = POInfo.getPOInfo(Env.getCtx(), table.getAD_Table_ID(), trxName);
|
||||
if (info == null) return null;
|
||||
StringBuffer sqlBuffer = info.buildSelect();
|
||||
if (whereClause != null && whereClause.trim().length() > 0)
|
||||
|
@ -210,7 +210,7 @@ public class Query {
|
|||
* @throws SQLException
|
||||
*/
|
||||
public POResultSet scroll() throws SQLException {
|
||||
POInfo info = POInfo.getPOInfo(Env.getCtx(), table.getAD_Table_ID());
|
||||
POInfo info = POInfo.getPOInfo(Env.getCtx(), table.getAD_Table_ID(), trxName);
|
||||
if (info == null) return null;
|
||||
StringBuffer sqlBuffer = info.buildSelect();
|
||||
if (whereClause != null && whereClause.trim().length() > 0)
|
||||
|
|
Loading…
Reference in New Issue