From 17560dba8e737cbbf7ae42cf3198641f64a435ee Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Thu, 21 Mar 2013 13:26:49 -0500 Subject: [PATCH] IDEMPIERE-720 UUID Generator doesn't work #resolve --- .../src/org/adempiere/process/UUIDGenerator.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/org.adempiere.base/src/org/adempiere/process/UUIDGenerator.java b/org.adempiere.base/src/org/adempiere/process/UUIDGenerator.java index 1931a52e08..50f2048d5c 100644 --- a/org.adempiere.base/src/org/adempiere/process/UUIDGenerator.java +++ b/org.adempiere.base/src/org/adempiere/process/UUIDGenerator.java @@ -23,6 +23,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.UUID; +import java.util.logging.Level; import org.adempiere.exceptions.DBException; import org.compiere.model.MColumn; @@ -48,6 +49,9 @@ public class UUIDGenerator extends SvrProcess { private String tableName; + /** Logger */ + private static CLogger log = CLogger.getCLogger(UUIDGenerator.class); + /** * @see org.compiere.process.SvrProcess#prepare() */ @@ -94,7 +98,7 @@ public class UUIDGenerator extends SvrProcess { String columnName = PO.getUUIDColumnName(cTableName); int AD_Column_ID = DB.getSQLValue(null, "SELECT AD_Column_ID FROM AD_Column Where AD_Table_ID = ? AND ColumnName = ?", AD_Table_ID, columnName); if (AD_Column_ID <= 0) { - System.out.println("Adding UUID to " + cTableName); + if (log.isLoggable(Level.INFO)) log.info("Adding UUID to " + cTableName); count++; //create column MColumn mColumn = new MColumn(getCtx(), 0, null); @@ -142,6 +146,10 @@ public class UUIDGenerator extends SvrProcess { } else { compositeKeys = Arrays.asList(table.getKeyColumns()); } + if ((compositeKeys == null || compositeKeys.size() == 0) && keyColumn == null) { + log.warning("Cannot update orphan table " + table.getTableName() + " (not ID neither parents)"); + return; + } if (compositeKeys == null) { sql.append(keyColumn); } else {