IDEMPIERE-303 AD_TreeNodeMM_UU is null after create one new menu item
This commit is contained in:
parent
da1443bf2d
commit
133c0450ae
|
@ -121,7 +121,7 @@ public class UUIDGenerator extends SvrProcess {
|
||||||
syncColumn(mColumn);
|
syncColumn(mColumn);
|
||||||
|
|
||||||
//update db
|
//update db
|
||||||
updateUUID(mColumn);
|
updateUUID(mColumn, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -130,7 +130,7 @@ public class UUIDGenerator extends SvrProcess {
|
||||||
return count + " table altered";
|
return count + " table altered";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void updateUUID(MColumn column) {
|
public static void updateUUID(MColumn column, String trxName) {
|
||||||
MTable table = (MTable) column.getAD_Table();
|
MTable table = (MTable) column.getAD_Table();
|
||||||
int AD_Column_ID = DB.getSQLValue(null, "SELECT AD_Column_ID FROM AD_Column WHERE AD_Table_ID=? AND ColumnName=?", table.getAD_Table_ID(), table.getTableName()+"_ID");
|
int AD_Column_ID = DB.getSQLValue(null, "SELECT AD_Column_ID FROM AD_Column WHERE AD_Table_ID=? AND ColumnName=?", table.getAD_Table_ID(), table.getTableName()+"_ID");
|
||||||
StringBuffer sql = new StringBuffer("SELECT ");
|
StringBuffer sql = new StringBuffer("SELECT ");
|
||||||
|
@ -160,12 +160,18 @@ public class UUIDGenerator extends SvrProcess {
|
||||||
}
|
}
|
||||||
updateSQL = updateSQL.substring(0, updateSQL.length() - " AND ".length());
|
updateSQL = updateSQL.substring(0, updateSQL.length() - " AND ".length());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean localTrx = false;
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
Trx trx = null;
|
Trx trx = trxName != null ? Trx.get(trxName, false) : null;
|
||||||
try {
|
if (trx == null) {
|
||||||
trx = Trx.get(Trx.createTrxName(), true);
|
trx = Trx.get(Trx.createTrxName(), true);
|
||||||
trx.start();
|
localTrx = true;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
if (localTrx)
|
||||||
|
trx.start();
|
||||||
stmt = DB.prepareStatement(sql.toString(), trx.getTrxName());
|
stmt = DB.prepareStatement(sql.toString(), trx.getTrxName());
|
||||||
stmt.setFetchSize(100);
|
stmt.setFetchSize(100);
|
||||||
rs = stmt.executeQuery();
|
rs = stmt.executeQuery();
|
||||||
|
@ -174,7 +180,7 @@ public class UUIDGenerator extends SvrProcess {
|
||||||
int recordId = rs.getInt(1);
|
int recordId = rs.getInt(1);
|
||||||
if (recordId > MTable.MAX_OFFICIAL_ID) {
|
if (recordId > MTable.MAX_OFFICIAL_ID) {
|
||||||
UUID uuid = UUID.randomUUID();
|
UUID uuid = UUID.randomUUID();
|
||||||
DB.executeUpdateEx(updateSQL,new Object[]{uuid.toString(), recordId},null);
|
DB.executeUpdateEx(updateSQL,new Object[]{uuid.toString(), recordId}, trx.getTrxName());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
UUID uuid = UUID.randomUUID();
|
UUID uuid = UUID.randomUUID();
|
||||||
|
@ -183,15 +189,22 @@ public class UUIDGenerator extends SvrProcess {
|
||||||
for (String s : compositeKeys) {
|
for (String s : compositeKeys) {
|
||||||
params.add(rs.getObject(s));
|
params.add(rs.getObject(s));
|
||||||
}
|
}
|
||||||
DB.executeUpdateEx(updateSQL,params.toArray(),null);
|
DB.executeUpdateEx(updateSQL,params.toArray(),trx.getTrxName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (localTrx) {
|
||||||
|
trx.commit(true);
|
||||||
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
|
if (localTrx) {
|
||||||
|
trx.rollback();
|
||||||
|
}
|
||||||
throw new DBException(e);
|
throw new DBException(e);
|
||||||
} finally {
|
} finally {
|
||||||
DB.close(rs, stmt);
|
DB.close(rs, stmt);
|
||||||
if (trx != null)
|
if (localTrx) {
|
||||||
trx.close();
|
trx.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3365,7 +3365,7 @@ public abstract class PO
|
||||||
int no = DB.executeUpdate(sql.toString(), m_trxName);
|
int no = DB.executeUpdate(sql.toString(), m_trxName);
|
||||||
if (uuidColumnId > 0 && !uuidFunction) {
|
if (uuidColumnId > 0 && !uuidFunction) {
|
||||||
MColumn column = new MColumn(getCtx(), uuidColumnId, get_TrxName());
|
MColumn column = new MColumn(getCtx(), uuidColumnId, get_TrxName());
|
||||||
UUIDGenerator.updateUUID(column);
|
UUIDGenerator.updateUUID(column, get_TrxName());
|
||||||
}
|
}
|
||||||
log.fine("#" + no);
|
log.fine("#" + no);
|
||||||
return no > 0;
|
return no > 0;
|
||||||
|
@ -3548,7 +3548,7 @@ public abstract class PO
|
||||||
//fall back to the slow java client update code
|
//fall back to the slow java client update code
|
||||||
if (uuidColumnId > 0 && !uuidFunction) {
|
if (uuidColumnId > 0 && !uuidFunction) {
|
||||||
MColumn column = new MColumn(getCtx(), uuidColumnId, get_TrxName());
|
MColumn column = new MColumn(getCtx(), uuidColumnId, get_TrxName());
|
||||||
UUIDGenerator.updateUUID(column);
|
UUIDGenerator.updateUUID(column, get_TrxName());
|
||||||
}
|
}
|
||||||
return no > 0;
|
return no > 0;
|
||||||
} // insert_Accounting
|
} // insert_Accounting
|
||||||
|
@ -3626,7 +3626,7 @@ public abstract class PO
|
||||||
if (uuidColumnId > 0 && !uuidFunction )
|
if (uuidColumnId > 0 && !uuidFunction )
|
||||||
{
|
{
|
||||||
MColumn column = new MColumn(getCtx(), uuidColumnId, get_TrxName());
|
MColumn column = new MColumn(getCtx(), uuidColumnId, get_TrxName());
|
||||||
UUIDGenerator.updateUUID(column);
|
UUIDGenerator.updateUUID(column, get_TrxName());
|
||||||
}
|
}
|
||||||
return no > 0;
|
return no > 0;
|
||||||
} // insert_Tree
|
} // insert_Tree
|
||||||
|
|
Loading…
Reference in New Issue