Package org.eclipse.edc.sql.translation
Class SqlQueryStatement
java.lang.Object
org.eclipse.edc.sql.translation.SqlQueryStatement
Maps a
QuerySpec to a single SQL SELECT ... FROM ... WHERE ... statement. The SELECT ... part
is passed in through the constructor, and the rest of the query is assembled dynamically, based on the
QuerySpec and the TranslationMapping.-
Constructor Summary
ConstructorsConstructorDescriptionSqlQueryStatement(String selectStatement, int limit, int offset) Initializes this SQL Query Statement with a SELECT clause, LIMIT and OFFSET values.SqlQueryStatement(String selectStatement, org.eclipse.edc.spi.query.QuerySpec query, TranslationMapping rootModel, CriterionToWhereClauseConverter criterionToWhereClauseConverter) Initializes this SQL Query Statement with a SELECT clause, aQuerySpec, a translation mapping and a criterion converterSqlQueryStatement(String selectStatement, org.eclipse.edc.spi.query.QuerySpec query, TranslationMapping rootModel, SqlOperatorTranslator operatorTranslator) Initializes this SQL Query Statement. -
Method Summary
Modifier and TypeMethodDescriptionaddWhereClause(String clause, Object... parameters) Add where clause with related parameters.Object[]SQL supports parameter substitution (in prepared statements), this method returns a list of those placeholders.Represents this query as SQL string, including parameter placeholders (?)
-
Constructor Details
-
SqlQueryStatement
public SqlQueryStatement(String selectStatement, org.eclipse.edc.spi.query.QuerySpec query, TranslationMapping rootModel, SqlOperatorTranslator operatorTranslator) Initializes this SQL Query Statement.- Parameters:
selectStatement- The SELECT clause, e.g.SELECT * FROM your_tablequery- aQuerySpecthat contains a query in the canonical formatrootModel- ATranslationMappingthat enables mapping from canonical to the SQL-specific model/formatoperatorTranslator- theSqlOperatorTranslatorinstance.
-
SqlQueryStatement
public SqlQueryStatement(String selectStatement, org.eclipse.edc.spi.query.QuerySpec query, TranslationMapping rootModel, CriterionToWhereClauseConverter criterionToWhereClauseConverter) Initializes this SQL Query Statement with a SELECT clause, aQuerySpec, a translation mapping and a criterion converter- Parameters:
selectStatement- The SELECT clause, e.g.SELECT * FROM your_tablequery- aQuerySpecthat contains a query in the canonical formatrootModel- ATranslationMappingthat enables mapping from canonical to the SQL-specific model/formatcriterionToWhereClauseConverter- Converts criterion to where condition clauses
-
SqlQueryStatement
Initializes this SQL Query Statement with a SELECT clause, LIMIT and OFFSET values.- Parameters:
selectStatement- The SELECT clause, e.g.SELECT * FROM your_tablelimit- the limit value.offset- the offset value.
-
-
Method Details
-
getQueryAsString
Represents this query as SQL string, including parameter placeholders (?)- Returns:
- the query as SQL statement
-
getParameters
SQL supports parameter substitution (in prepared statements), this method returns a list of those placeholders.- Returns:
- an array of parameters that can be used for prepared statements
-
addWhereClause
Add where clause with related parameters. If it contains multiple clauses better wrap it with parenthesis- Parameters:
clause- the SQL where clause.parameters- the parameters.- Returns:
- self.
-