Class SqlGenerator

java.lang.Object
org.springframework.data.jdbc.core.convert.SqlGenerator

public class SqlGenerator extends Object
Generates SQL statements to be used by SimpleJdbcRepository
Author:
Jens Schauder, Yoichi Imai, Bastian Wilhelm, Oleksandr Kucher, Mark Paluch, Tom Hombergs, Tyler Van Gorder, Milan Milanov, Myeonghyeon Lee, Mikhail Polivakha, Chirag Tailor, Diego Krupitza, Hari Ohm Prasath, Viktor Ardelean, Kurt Niemi
  • Method Details

    • createSelectBuilder

      public SelectBuilder.SelectWhere createSelectBuilder(Table table, Predicate<AggregatePath> pathFilter)
      Create a basic select structure with all the necessary joins
      Parameters:
      table - the table to base the select on
      pathFilter - a filter for excluding paths from the select. All paths for which the filter returns true will be skipped when determining columns to select.
      Returns:
      a select structure suitable for constructing more specialized selects by adding conditions.
      Since:
      4.0
    • extractEmbeddedPropertyName

      public String extractEmbeddedPropertyName(Sort.Order order)
    • extractFieldNameFromEmbeddedProperty

      public String extractFieldNameFromEmbeddedProperty(Sort.Order order)
    • selectByQuery

      public String selectByQuery(Query query, MapSqlParameterSource parameterSource)
      Constructs a single sql query that performs select based on the provided query. Additional the bindings for the where clause are stored after execution into the parameterSource
      Parameters:
      query - the query to base the select on. Must not be null
      parameterSource - the source for holding the bindings
      Returns:
      a non null query string.
    • selectByQuery

      public String selectByQuery(Query query, MapSqlParameterSource parameterSource, Pageable pageable)
      Constructs a single sql query that performs select based on the provided query and pagination information. Additional the bindings for the where clause are stored after execution into the parameterSource
      Parameters:
      query - the query to base the select on. Must not be null.
      parameterSource - the source for holding the bindings.
      pageable - the pageable to perform on the select.
      Returns:
      a non null query string.
    • existsByQuery

      public String existsByQuery(Query query, MapSqlParameterSource parameterSource)
      Constructs a single sql query that performs select count based on the provided query for checking existence. Additional the bindings for the where clause are stored after execution into the parameterSource
      Parameters:
      query - the query to base the select on. Must not be null
      parameterSource - the source for holding the bindings
      Returns:
      a non null query string.
    • countByQuery

      public String countByQuery(Query query, MapSqlParameterSource parameterSource)
      Constructs a single sql query that performs select count based on the provided query. Additional the bindings for the where clause are stored after execution into the parameterSource
      Parameters:
      query - the query to base the select on. Must not be null
      parameterSource - the source for holding the bindings
      Returns:
      a non null query string.