コード例 #1
0
ファイル: DbUtils.java プロジェクト: miagosen/market
  public void replace(Object entity) throws DbException {
    try {
      beginTransaction();

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

      setTransactionSuccessful();
    } finally {
      endTransaction();
    }
  }
コード例 #2
0
ファイル: DbUtils.java プロジェクト: miagosen/market
 // ***************************** 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
ファイル: DbUtils.java プロジェクト: miagosen/market
  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();
    }
  }