Exemple #1
0
 public int delete() {
   SQLStatement stat = new SQLStatement(db);
   stat.appendSQL("DELETE FROM ");
   from.appendSQL(stat);
   appendWhere(stat);
   StatementLogger.delete(stat.getSQL());
   return stat.executeUpdate();
 }
Exemple #2
0
 public int update() {
   if (updateColumnDeclarations.size() == 0) {
     throw new RuntimeException("Missing set or increment call.");
   }
   SQLStatement stat = new SQLStatement(db);
   stat.appendSQL("UPDATE ");
   from.appendSQL(stat);
   stat.appendSQL(" SET ");
   int i = 0;
   for (UpdateColumn declaration : updateColumnDeclarations) {
     if (i++ > 0) {
       stat.appendSQL(", ");
     }
     declaration.appendSQL(stat);
   }
   appendWhere(stat);
   StatementLogger.update(stat.getSQL());
   return stat.executeUpdate();
 }
Exemple #3
0
 @SuppressWarnings("unchecked")
 void appendFromWhere(SQLStatement stat) {
   stat.appendSQL(" FROM ");
   from.appendSQL(stat);
   for (SelectTable join : joins) {
     join.appendSQLAsJoin(stat, this);
   }
   appendWhere(stat);
   if (groupByExpressions != null) {
     stat.appendSQL(" GROUP BY ");
     int i = 0;
     for (Object obj : groupByExpressions) {
       if (i++ > 0) {
         stat.appendSQL(", ");
       }
       appendSQL(stat, obj);
       stat.appendSQL(" ");
     }
   }
   if (!orderByList.isEmpty()) {
     stat.appendSQL(" ORDER BY ");
     int i = 0;
     for (OrderExpression<T> o : orderByList) {
       if (i++ > 0) {
         stat.appendSQL(", ");
       }
       o.appendSQL(stat);
       stat.appendSQL(" ");
     }
   }
   if (limit > 0) {
     db.getDialect().appendLimit(stat, limit);
   }
   if (offset > 0) {
     db.getDialect().appendOffset(stat, offset);
   }
   StatementLogger.select(stat.getSQL());
 }