//create a new field of the right type in toTable
ensureColumnExists(toTable, colName, nuObjectStack.getRepresentation(toLevel).getReturnType(colName), cw);
IdStatementGenerator idGen = new IdStatementGenerator(adapter, nuObjectStack, true);
int minLevel = Math.min(fromLevel, toLevel);
String idStatement = idGen.generate(minLevel);
StringBuilder sb = new StringBuilder("UPDATE ");
sb.append(toTable);
sb.append(" AS ");
sb.append(toTableAs);
sb.append(" SET ");
sb.append(toTableAs);
sb.append(".");
sb.append(colName);
sb.append("= ( SELECT ");
sb.append(fromTableAs);
sb.append(".");
sb.append(colName);
sb.append(" FROM ");
sb.append(idGen.generateAsStatement(new String[]{toTable}));
sb.append(" WHERE ");
sb.append(idStatement);
sb.append(")");
PreparedStatement ps = cw.prepareStatement(sb.toString());
int index = 0;
for (RelationDescriptor o : idGen.getRelationDescriptors())
{
if(o.isRequiresvalue())
{
index++;
Tools.setParameter(ps, o.getValue().getClass(), index,o.getValue());