Package com.github.vlachenal.sql
Class SelectBuilder
- java.lang.Object
-
- com.github.vlachenal.sql.SelectBuilder
-
public class SelectBuilder extends java.lang.Object- Since:
- 0.1
-
-
Constructor Summary
Constructors Constructor Description SelectBuilder()SelectBuilderconstructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SQLQuerybuild()Build SQL querySelectBuilderdistinct()AddDISTINCTcommandSelectBuilderfetch(long limit)AddFETCH FIRST n ROWS ONLYFieldsBuilderfield(java.lang.String column)Return a new field builderFieldsBuildergroupBy(java.lang.String column)Add SQLGROUP BYcommandSelectBuilderhaving(ClausesBuilder clauses)Add SQLHAVINGcommand and its clauses if not emptySelectBuilderoffset(long offset)AddOFFSET n ROWSFieldsBuilderorderBy(java.lang.String column)Add SQLORDER BYcommand.java.lang.StringtoString()Get SQL query.
SelectBuilderunion(SelectBuilder other)AddUNIONto other SQL requestSelectBuilderunionAll(SelectBuilder other)AddUNION ALLto other SQL request with duplicate entries
-
-
-
Constructor Detail
-
SelectBuilder
public SelectBuilder()
SelectBuilderconstructor
-
-
Method Detail
-
distinct
public SelectBuilder distinct()
AddDISTINCTcommand- Returns:
this
-
toString
public java.lang.String toString()
Get SQL query.
- Overrides:
toStringin classjava.lang.Object
-
field
public FieldsBuilder field(java.lang.String column)
Return a new field builder- Parameters:
column- the selected column- Returns:
- the new
FieldsBuilder
-
groupBy
public FieldsBuilder groupBy(java.lang.String column)
Add SQLGROUP BYcommand- Parameters:
column- the first column to group by- Returns:
- a new
FieldsBuilderto add other columns
-
orderBy
public FieldsBuilder orderBy(java.lang.String column)
Add SQLORDER BYcommand.- Parameters:
column- the first column to order by- Returns:
- a new
FieldsBuilderto add other columns
-
having
public SelectBuilder having(ClausesBuilder clauses)
Add SQLHAVINGcommand and its clauses if not empty- Parameters:
clauses- the clauses- Returns:
this
-
union
public SelectBuilder union(SelectBuilder other)
AddUNIONto other SQL request- Parameters:
other- the other SQL request- Returns:
this
-
unionAll
public SelectBuilder unionAll(SelectBuilder other)
AddUNION ALLto other SQL request with duplicate entries- Parameters:
other- the other SQL request- Returns:
this
-
offset
public SelectBuilder offset(long offset)
AddOFFSET n ROWS- Parameters:
offset- the offset value- Returns:
this
-
fetch
public SelectBuilder fetch(long limit)
AddFETCH FIRST n ROWS ONLY- Parameters:
limit- the limit value- Returns:
this
-
build
public SQLQuery build()
Build SQL query- Returns:
- the query and its prepared statement values
-
-