public class SqlLookup
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
SqlLookup.Distinct |
static class |
SqlLookup.Order |
(package private) class |
SqlLookup.WhereContainer |
Modifier and Type | Field and Description |
---|---|
static int |
ALL |
static int |
ASC |
protected boolean |
built |
protected java.util.Map<java.lang.String,java.util.List<DataNode>> |
constraints |
static int |
DESC |
static int |
DISTINCT |
static int |
DISTINCTROW |
protected int |
duplicateAction |
protected boolean |
forUpdate |
protected java.lang.String[] |
groupBy |
protected int |
groupDirection |
protected int |
limit |
protected java.util.Map<java.lang.String,java.util.Set<java.lang.String>> |
lookups |
static int |
NO_ORDER |
protected int |
offset |
protected java.util.ArrayList<java.lang.String[]> |
order |
protected int |
orderDirection |
protected DmPreparedStatement |
ps |
protected java.lang.String |
quote |
protected java.lang.String |
schemaName |
protected DatabaseSchema |
schemas |
protected java.util.Set<java.lang.String> |
updateColumns |
Constructor and Description |
---|
SqlLookup(DatabaseSchema schemas,
java.lang.String quote,
java.lang.String schemaName)
Creates a new SqlLookup
|
Modifier and Type | Method and Description |
---|---|
void |
addConstraint(java.lang.String table,
java.util.Map<java.lang.String,?> whereData) |
void |
addConstraint(java.lang.String table,
java.lang.String column,
java.lang.Object value)
add constraints (where clause) to the query
|
void |
addGroupBy(BasicSchema schema,
java.lang.String column)
add group by to the query
|
void |
addOrder(BasicSchema schema,
java.lang.String column)
add order by to the query
|
void |
addSelectColumns(java.lang.String table,
java.util.Collection<java.lang.String> selectColumns)
add columns you wish to select with the statement
|
protected void |
buildQuery(java.sql.Connection con)
build the query
|
(package private) SqlLookup.WhereContainer |
buildWhere() |
DmPreparedStatement |
getPreparedStatement(java.sql.Connection con)
retrieves the completed PreparedStatement.
|
protected java.lang.String |
quoteValue(java.lang.String input) |
void |
setDuplicateAction(int duplicateAction)
set what to do on a duplicate
|
void |
setForUpdate(java.util.Set<java.lang.String> columns) |
void |
setGroupDirection(int order)
set the group direction(ascending or descending)
|
void |
setLimit(int limit)
set a limit for the number of rows returned
|
void |
setOffset(int offset)
set the offset of the query
|
void |
setOrderDirection(int order)
set the order by direction (ascending or descending)
|
@Nullable protected final java.lang.String schemaName
protected int offset
protected int limit
protected int orderDirection
protected int groupDirection
protected int duplicateAction
protected boolean built
protected java.util.ArrayList<java.lang.String[]> order
protected java.lang.String[] groupBy
@Nullable protected DmPreparedStatement ps
protected java.util.Map<java.lang.String,java.util.List<DataNode>> constraints
protected java.util.Map<java.lang.String,java.util.Set<java.lang.String>> lookups
protected DatabaseSchema schemas
protected boolean forUpdate
protected java.util.Set<java.lang.String> updateColumns
protected final java.lang.String quote
public static final int ASC
public static final int DESC
public static final int NO_ORDER
public static final int ALL
public static final int DISTINCT
public static final int DISTINCTROW
public SqlLookup(DatabaseSchema schemas, java.lang.String quote, @Nullable java.lang.String schemaName)
schemas
- @Nullable public DmPreparedStatement getPreparedStatement(@NotNull java.sql.Connection con) throws java.sql.SQLException
con
- java.sql.SQLException
public void addSelectColumns(java.lang.String table, @Nullable java.util.Collection<java.lang.String> selectColumns)
table
- selectColumns
- public void addConstraint(java.lang.String table, @Nullable java.util.Map<java.lang.String,?> whereData) throws java.io.UnsupportedEncodingException
java.io.UnsupportedEncodingException
public void addConstraint(java.lang.String table, java.lang.String column, java.lang.Object value) throws java.io.UnsupportedEncodingException
table
- column
- value
- java.io.UnsupportedEncodingException
public void addOrder(@NotNull BasicSchema schema, java.lang.String column)
schema
- column
- public void addGroupBy(@NotNull BasicSchema schema, java.lang.String column)
schema
- column
- public void setGroupDirection(int order)
order
- public void setDuplicateAction(int duplicateAction)
duplicateAction
- public void setOrderDirection(int order)
order
- public void setLimit(int limit)
limit
- public void setOffset(int offset)
offset
- protected void buildQuery(@NotNull java.sql.Connection con) throws java.sql.SQLException
con
- java.sql.SQLException
public void setForUpdate(java.util.Set<java.lang.String> columns)
@NotNull protected java.lang.String quoteValue(java.lang.String input)
@NotNull SqlLookup.WhereContainer buildWhere()