public static class SmartQuery.Compiler extends Object
SmartQuery
.Modifier and Type | Field and Description |
---|---|
protected AtomicInteger |
aliasCounter |
protected String |
defaultAlias |
protected EntityDescriptor |
ed |
protected StringBuilder |
joins |
protected Map<String,sirius.kernel.commons.Tuple<String,EntityDescriptor>> |
joinTable |
protected List<Object> |
parameters |
protected StringBuilder |
postJoinQuery |
protected StringBuilder |
preJoinQuery |
protected sirius.db.jdbc.SmartQuery.Compiler.JoinFetch |
rootFetch |
Constructor and Description |
---|
Compiler(EntityDescriptor ed)
Creates a new compiler for the given entity descriptor.
|
Modifier and Type | Method and Description |
---|---|
void |
addParameter(Object parameter)
Adds a query parameter.
|
TranslationState |
captureAndReplaceTranslationState(String newDefaultAlias,
EntityDescriptor newDefaultDescriptor)
Returns the currently active translation state and replaces all settings for the new alias and base descriptor.
|
protected void |
executeJoinFetches(SQLEntity entity,
Set<String> columns,
ResultSet rs) |
String |
generateTableAlias()
Generates an unique table alias.
|
StringBuilder |
getJoins()
Provides access to the currently generated JOINs.
|
protected String |
getQuery() |
StringBuilder |
getSELECTBuilder()
Provides access to the string builder which generates the SELECT part of the query.
|
StringBuilder |
getWHEREBuilder()
Provides access to the string builder which generates the WHERE part of the query.
|
void |
restoreTranslationState(TranslationState state)
Restores a previously captured translation state.
|
void |
setWHEREBuilder(StringBuilder newWHEREBuilder) |
String |
toString() |
String |
translateColumnName(Mapping column)
Translates a column name into an effective name by applying aliases and rewrites.
|
protected EntityDescriptor ed
protected StringBuilder preJoinQuery
protected StringBuilder joins
protected StringBuilder postJoinQuery
protected Map<String,sirius.kernel.commons.Tuple<String,EntityDescriptor>> joinTable
protected AtomicInteger aliasCounter
protected String defaultAlias
protected sirius.db.jdbc.SmartQuery.Compiler.JoinFetch rootFetch
public Compiler(@Nullable EntityDescriptor ed)
ed
- the entity descriptor which is used to determine which table to select and how to JOIN other
entities.public StringBuilder getSELECTBuilder()
public StringBuilder getWHEREBuilder()
public void setWHEREBuilder(StringBuilder newWHEREBuilder)
public String generateTableAlias()
public TranslationState captureAndReplaceTranslationState(String newDefaultAlias, EntityDescriptor newDefaultDescriptor)
To restore the state, restoreTranslationState(TranslationState)
can be used.
newDefaultAlias
- specifies the new default alias to usenewDefaultDescriptor
- specifies the new main / default descriptor to usepublic StringBuilder getJoins()
public void restoreTranslationState(TranslationState state)
state
- the original state to restorepublic String translateColumnName(Mapping column)
column
- the column to translateprotected void executeJoinFetches(SQLEntity entity, Set<String> columns, ResultSet rs)
public void addParameter(Object parameter)
parameter
- the parameter to addprotected String getQuery()
Copyright © 2018. All rights reserved.