java.lang.Object
org.litebridge.db.spi.impl.sql.AbstractSqlGenerator
org.litebridge.db.spi.impl.sql.SelectSqlGenerator
SQL generator for SELECT statements.
-
Field Summary
Fields inherited from class org.litebridge.db.spi.impl.sql.AbstractSqlGenerator
columnIdentifierGenerator, typeConverter -
Constructor Summary
ConstructorsConstructorDescriptionSelectSqlGenerator(TypeConverter typeConverter, ColumnIdentifierGenerator columnIdentifierGenerator, BiFunction<Table, ConnectionProvider, TableMetaData> ensureTableMetaData) Creates a newSelectSqlGenerator. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidappendLimitClause(Limit limit, StringBuilder sql) Appends a LIMIT clause to the SQL.protected PreparedSqlcreateJoin(Join join, Select operation, ConnectionProvider connectionProvider) Create a SQL JOIN clause based on the providedJoinobject.prepareSql(Select select, ConnectionProvider connectionProvider) Prepares a SQL SELECT statement along with its bind values for execution.prepareSql(Select select, ConnectionProvider connectionProvider, @Nullable Operation parentOperation) Prepares a SQL SELECT statement along with its bind values for execution.Methods inherited from class org.litebridge.db.spi.impl.sql.AbstractSqlGenerator
appendConditionsAndSubgroups, appendTable, appendTable, createBindValue, createCondition, ensureColumnMetaData, ensureTableMetaData, getExpressionValue, mapOperator
-
Constructor Details
-
SelectSqlGenerator
public SelectSqlGenerator(TypeConverter typeConverter, ColumnIdentifierGenerator columnIdentifierGenerator, BiFunction<Table, ConnectionProvider, TableMetaData> ensureTableMetaData) Creates a newSelectSqlGenerator.- Parameters:
typeConverter- the type convertercolumnIdentifierGenerator- the column identifier generatorensureTableMetaData- a function to ensure table metadata
-
-
Method Details
-
prepareSql
Prepares a SQL SELECT statement along with its bind values for execution.- Parameters:
select- the select operationconnectionProvider- the connection provider- Returns:
- a
PreparedSqlobject containing the generated SQL query string and the list of bind values
-
prepareSql
public PreparedSql prepareSql(Select select, ConnectionProvider connectionProvider, @Nullable Operation parentOperation) Prepares a SQL SELECT statement along with its bind values for execution.- Parameters:
select- the select operationconnectionProvider- the connection providerparentOperation- the parent operation, if any- Returns:
- a
PreparedSqlobject containing the generated SQL query string and the list of bind values
-
createJoin
protected PreparedSql createJoin(Join join, Select operation, ConnectionProvider connectionProvider) Create a SQL JOIN clause based on the providedJoinobject.The join clause is constructed by specifying the target table, optional schema, and any associated conditions for the join operation. Conditional logic is applied to determine the join type (e.g., ON or USING) and format the resulting SQL string.
- Parameters:
join- theJoinobject containing the target table information and the list of conditions defining the join relationshipoperation- the select operationconnectionProvider- the connection provider- Returns:
- Prepared SQL join clause
-
appendLimitClause
Appends a LIMIT clause to the SQL.- Parameters:
limit- the limitsql- the SQL string builder
-