Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
package ca.krasnay.sqlbuilder;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
/**
* Tool for programmatically constructing SQL select statements. This class aims
* to simplify the task of juggling commas and SQL keywords when building SQL
* statements from scratch, but doesn't attempt to do much beyond that. Here are
* some relatively complex examples:
*
*
* String sql = new SelectBuilder()
* .column("e.id")
* .column("e.name as empname")
* .column("d.name as deptname")
* .column("e.salary")
* .from(("Employee e")
* .join("Department d on e.dept_id = d.id")
* .where("e.salary > 100000")
* .orderBy("e.salary desc")
* .toString();
*
*
*
* String sql = new SelectBuilder()
* .column("d.id")
* .column("d.name")
* .column("sum(e.salary) as total")
* .from("Department d")
* .join("Employee e on e.dept_id = d.id")
* .groupBy("d.id")
* .groupBy("d.name")
* .having("total > 1000000").toString();
*
*
* Note that the methods can be called in any order. This is handy when a base
* class wants to create a simple query but allow subclasses to augment it.
*
* It's similar to the Squiggle SQL library
* (http://code.google.com/p/squiggle-sql/), but makes fewer assumptions about
* the internal structure of the SQL statement, which I think makes for simpler,
* cleaner code. For example, in Squiggle you would write...
*
*
*
* With SelectBuilder, we assume you know how to write SQL expressions, so
* instead you would write...
*
*
* select.where("status = 'processed'");
*
*
* To include parameters, it's highly recommended to use the
* {@link ParameterizedPreparedStatementCreatorTest}, like this:
*
*
* String sql = new SelectBuilder("Employee e")
* .where("name like :name")
* .toString();
*
* PreparedStatement ps = new ParameterizedPreparedStatementCreator(sql)
* .setParameter("name", "Bob%")
* .createPreparedStatement(conn);
*
*
*
* @author John Krasnay
*/
public class SelectBuilder extends AbstractSqlBuilder implements Cloneable, Serializable {
private static final long serialVersionUID = 1;
private boolean distinct;
private List