Connection conn = Transaction.begin(DcontractPeer.DATABASE_NAME);
boolean success = false;
try {
entry.save(conn);
entry.setDcontractCode(getRowCode("CO", entry.getDcontractId()));
entry.save(conn);
Transaction.commit(conn);
success = true;
} finally {
if (!success) Transaction.safeRollback(conn);