示例#1
0
  public void replace(Object entity) throws DbException {
    try {
      beginTransaction();

      createTableIfNotExist(entity.getClass());
      execNonQuery(SqlInfoBuilder.buildReplaceSqlInfo(this, entity));

      setTransactionSuccessful();
    } finally {
      endTransaction();
    }
  }
示例#2
0
 // ***************************** private operations with out transaction
 // *****************************
 private void saveOrUpdateWithoutTransaction(Object entity) throws DbException {
   Table table = Table.get(this, entity.getClass());
   Id id = table.id;
   if (id.isAutoIncrement()) {
     if (id.getColumnValue(entity) != null) {
       execNonQuery(SqlInfoBuilder.buildUpdateSqlInfo(this, entity));
     } else {
       saveBindingIdWithoutTransaction(entity);
     }
   } else {
     execNonQuery(SqlInfoBuilder.buildReplaceSqlInfo(this, entity));
   }
 }
示例#3
0
  public void replaceAll(List<?> entities) throws DbException {
    if (entities == null || entities.size() == 0) return;
    try {
      beginTransaction();

      createTableIfNotExist(entities.get(0).getClass());
      for (Object entity : entities) {
        execNonQuery(SqlInfoBuilder.buildReplaceSqlInfo(this, entity));
      }

      setTransactionSuccessful();
    } finally {
      endTransaction();
    }
  }