Exemple #1
0
 private boolean saveBindingIdWithoutTransaction(Object entity) throws DbException {
   Class<?> entityType = entity.getClass();
   Table table = Table.get(this, entityType);
   Id idColumn = table.id;
   if (idColumn.isAutoIncrement()) {
     execNonQuery(SqlInfoBuilder.buildInsertSqlInfo(this, entity));
     long id = getLastAutoIncrementId(table.tableName);
     if (id == -1) {
       return false;
     }
     idColumn.setAutoIncrementId(entity, id);
     return true;
   } else {
     execNonQuery(SqlInfoBuilder.buildInsertSqlInfo(this, entity));
     return true;
   }
 }
Exemple #2
0
  public void save(Object entity) throws DbException {
    try {
      beginTransaction();

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

      setTransactionSuccessful();
    } finally {
      endTransaction();
    }
  }
Exemple #3
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();
    }
  }