示例#1
0
  public void delete(Class<?> entityType, WhereBuilder whereBuilder) throws DbException {
    if (!tableIsExist(entityType)) return;
    try {
      beginTransaction();

      execNonQuery(SqlInfoBuilder.buildDeleteSqlInfo(this, entityType, whereBuilder));

      setTransactionSuccessful();
    } finally {
      endTransaction();
    }
  }
示例#2
0
  public void update(Object entity, String... updateColumnNames) throws DbException {
    if (!tableIsExist(entity.getClass())) return;
    try {
      beginTransaction();

      execNonQuery(SqlInfoBuilder.buildUpdateSqlInfo(this, entity, updateColumnNames));

      setTransactionSuccessful();
    } finally {
      endTransaction();
    }
  }
示例#3
0
  public void save(Object entity) throws DbException {
    try {
      beginTransaction();

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

      setTransactionSuccessful();
    } finally {
      endTransaction();
    }
  }
示例#4
0
  public void delete(Object entity) throws DbException {
    if (!tableIsExist(entity.getClass())) return;
    try {
      beginTransaction();

      execNonQuery(SqlInfoBuilder.buildDeleteSqlInfo(this, entity));

      setTransactionSuccessful();
    } finally {
      endTransaction();
    }
  }
示例#5
0
  public void saveOrUpdate(Object entity) throws DbException {
    try {
      beginTransaction();

      createTableIfNotExist(entity.getClass());
      saveOrUpdateWithoutTransaction(entity);

      setTransactionSuccessful();
    } finally {
      endTransaction();
    }
  }
示例#6
0
  public boolean saveBindingId(Object entity) throws DbException {
    boolean result = false;
    try {
      beginTransaction();

      createTableIfNotExist(entity.getClass());
      result = saveBindingIdWithoutTransaction(entity);

      setTransactionSuccessful();
    } finally {
      endTransaction();
    }
    return result;
  }
示例#7
0
  public void updateAll(List<?> entities, String... updateColumnNames) throws DbException {
    if (entities == null || entities.size() == 0 || !tableIsExist(entities.get(0).getClass()))
      return;
    try {
      beginTransaction();

      for (Object entity : entities) {
        execNonQuery(SqlInfoBuilder.buildUpdateSqlInfo(this, entity, updateColumnNames));
      }

      setTransactionSuccessful();
    } finally {
      endTransaction();
    }
  }
示例#8
0
  public void saveAll(List<?> entities) throws DbException {
    if (entities == null || entities.size() == 0) return;
    try {
      beginTransaction();

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

      setTransactionSuccessful();
    } finally {
      endTransaction();
    }
  }
示例#9
0
  public void saveOrUpdateAll(List<?> entities) throws DbException {
    if (entities == null || entities.size() == 0) return;
    try {
      beginTransaction();

      createTableIfNotExist(entities.get(0).getClass());
      for (Object entity : entities) {
        saveOrUpdateWithoutTransaction(entity);
      }

      setTransactionSuccessful();
    } finally {
      endTransaction();
    }
  }
示例#10
0
  public void saveBindingIdAll(List<?> entities) throws DbException {
    if (entities == null || entities.size() == 0) return;
    try {
      beginTransaction();

      createTableIfNotExist(entities.get(0).getClass());
      for (Object entity : entities) {
        if (!saveBindingIdWithoutTransaction(entity)) {
          throw new DbException("saveBindingId error, transaction will not commit!");
        }
      }

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