Spring Data JDBC Extensions

org.springframework.data.jdbc.query
Interface QueryDslJdbcOperations

All Known Implementing Classes:
QueryDslJdbcTemplate

public interface QueryDslJdbcOperations

Interface specifying a basic set of JDBC operations allowing the use of QueryDSL features for these operations.

This is an alternative to the classic JdbcOperations interface and is implemented by QueryDslJdbcTemplate. This interface is not often used directly, but provides a useful option to enhance testability, as it can easily be mocked or stubbed.

Since:
1.0
Author:
Thomas Risberg
See Also:
QueryDslJdbcTemplate, JdbcOperations

Method Summary
 long count(com.mysema.query.sql.SQLQuery sqlQuery)
          Count the rows that are part of the results for the given SQLQuery
 long countDistinct(com.mysema.query.sql.SQLQuery sqlQuery)
          Count the distinct rows that are part of the results for the given SQLQuery
 long delete(com.mysema.query.sql.RelationalPath<?> entity, SqlDeleteCallback callback)
          Execute a database delete using the provided SqlDeleteCallback.
 boolean exists(com.mysema.query.sql.SQLQuery sqlQuery)
          Determine if the result for the given SQLQuery contains some rows
 JdbcOperations getJdbcOperations()
          Expose the classic Spring JdbcTemplate to allow invocation of classic JDBC operations.
 long insert(com.mysema.query.sql.RelationalPath<?> entity, SqlInsertCallback callback)
          Execute a database insert using the provided SqlInsertCallback.
<K> K
insertWithKey(com.mysema.query.sql.RelationalPath<?> entity, SqlInsertWithKeyCallback<K> callback)
          Execute a database insert using the provided SqlInsertWithKeyCallback.
 com.mysema.query.sql.SQLQuery newSqlQuery()
          Create a new SQLQuery for this configuration.
 boolean notExists(com.mysema.query.sql.SQLQuery sqlQuery)
          Determine if the result for the given SQLQuery is empty
<T> List<T>
query(com.mysema.query.sql.SQLQuery sqlQuery, com.mysema.query.types.Expression<T> expression)
          Query for a list of objects using the SQLQuery.
<T> List<T>
query(com.mysema.query.sql.SQLQuery sqlQuery, ResultSetExtractor<List<T>> resultSetExtractor, com.mysema.query.types.Expression<?>... projection)
          Query for a list of objects using the SQLQuery.
<T> List<T>
query(com.mysema.query.sql.SQLQuery sqlQuery, RowMapper<T> rowMapper, com.mysema.query.types.Expression<?>... projection)
          Query for a list of objects using the SQLQuery.
<T> T
queryForObject(com.mysema.query.sql.SQLQuery sqlQuery, com.mysema.query.types.Expression<T> expression)
          Query for a single object using the SQLQuery.
<T> T
queryForObject(com.mysema.query.sql.SQLQuery sqlQuery, ResultSetExtractor<T> resultSetExtractor, com.mysema.query.types.Expression<?>... projection)
          Query for a single object using the SQLQuery.
<T> T
queryForObject(com.mysema.query.sql.SQLQuery sqlQuery, RowMapper<T> rowMapper, com.mysema.query.types.Expression<?>... projection)
          Query for a single object using the SQLQuery.
 long update(com.mysema.query.sql.RelationalPath<?> entity, SqlUpdateCallback callback)
          Execute a database update using the provided SqlUpdateCallback.
 

Method Detail

getJdbcOperations

JdbcOperations getJdbcOperations()
Expose the classic Spring JdbcTemplate to allow invocation of classic JDBC operations.


newSqlQuery

com.mysema.query.sql.SQLQuery newSqlQuery()
Create a new SQLQuery for this configuration.

Returns:
the new SQLQuery object

count

long count(com.mysema.query.sql.SQLQuery sqlQuery)
Count the rows that are part of the results for the given SQLQuery

Parameters:
sqlQuery - query to be used
Returns:
the count

countDistinct

long countDistinct(com.mysema.query.sql.SQLQuery sqlQuery)
Count the distinct rows that are part of the results for the given SQLQuery

Parameters:
sqlQuery - query to be used
Returns:
the count

exists

boolean exists(com.mysema.query.sql.SQLQuery sqlQuery)
Determine if the result for the given SQLQuery contains some rows

Parameters:
sqlQuery - query to be used
Returns:
whether result exist

notExists

boolean notExists(com.mysema.query.sql.SQLQuery sqlQuery)
Determine if the result for the given SQLQuery is empty

Parameters:
sqlQuery - query to be used
Returns:
whether result are empty

queryForObject

<T> T queryForObject(com.mysema.query.sql.SQLQuery sqlQuery,
                     ResultSetExtractor<T> resultSetExtractor,
                     com.mysema.query.types.Expression<?>... projection)
Query for a single object using the SQLQuery. The results are mapped using the RowMapper based on the specified projection.

Parameters:
sqlQuery - the SQLQuery to use
resultSetExtractor - the ResultSetExtractor to extract the results
projection - the column projection to be used for the mapping
Returns:
the mapped object

queryForObject

<T> T queryForObject(com.mysema.query.sql.SQLQuery sqlQuery,
                     RowMapper<T> rowMapper,
                     com.mysema.query.types.Expression<?>... projection)
Query for a single object using the SQLQuery. The results are mapped using the RowMapper based on the specified projection.

Parameters:
sqlQuery - the SQLQuery to use
rowMapper - the RowMapper to map the results
projection - the column projection to be used for the mapping
Returns:
the mapped object

queryForObject

<T> T queryForObject(com.mysema.query.sql.SQLQuery sqlQuery,
                     com.mysema.query.types.Expression<T> expression)
Query for a single object using the SQLQuery. The results are mapped using the Expression which could be a QBean or a MappingProjection.

Parameters:
sqlQuery - the SQLQuery to use
expression - the implementation to be used for the projection/mapping
Returns:
the mapped object

query

<T> List<T> query(com.mysema.query.sql.SQLQuery sqlQuery,
                  ResultSetExtractor<List<T>> resultSetExtractor,
                  com.mysema.query.types.Expression<?>... projection)
Query for a list of objects using the SQLQuery. The results are mapped using the RowMapper based on the specified projection.

Parameters:
sqlQuery - the SQLQuery to use
resultSetExtractor - the ResultSetExtractor to extract the results
projection - the column projection to be used for the mapping
Returns:
the mapped object

query

<T> List<T> query(com.mysema.query.sql.SQLQuery sqlQuery,
                  RowMapper<T> rowMapper,
                  com.mysema.query.types.Expression<?>... projection)
Query for a list of objects using the SQLQuery. The results are mapped using the RowMapper based on the specified projection.

Parameters:
sqlQuery - the SQLQuery to use
rowMapper - the RowMapper to map the results
projection - the column projection to be used for the mapping
Returns:
the mapped object

query

<T> List<T> query(com.mysema.query.sql.SQLQuery sqlQuery,
                  com.mysema.query.types.Expression<T> expression)
Query for a list of objects using the SQLQuery. The results are mapped using the Expression which could be a QBean or a MappingProjection.

Parameters:
sqlQuery - the SQLQuery to use
expression - the implementation to be used for the projection/mapping
Returns:
the mapped object

insert

long insert(com.mysema.query.sql.RelationalPath<?> entity,
            SqlInsertCallback callback)
Execute a database insert using the provided SqlInsertCallback.

Parameters:
entity - RelationalPath representing the table for the entity
callback - the SqlInsertCallback implementation that operates on the SQLInsertClause
Returns:
number of affected rows

insertWithKey

<K> K insertWithKey(com.mysema.query.sql.RelationalPath<?> entity,
                    SqlInsertWithKeyCallback<K> callback)
Execute a database insert using the provided SqlInsertWithKeyCallback.

Parameters:
entity - RelationalPath representing the table for the entity
callback - the SqlInsertWithKeyCallback implementation that operates on the SQLInsertClause
Returns:
the key of the inserted row

update

long update(com.mysema.query.sql.RelationalPath<?> entity,
            SqlUpdateCallback callback)
Execute a database update using the provided SqlUpdateCallback.

Parameters:
entity - RelationalPath representing the table for the entity
callback - the SqlUpdateCallback implementation that operates on the SQLUpdateClause
Returns:
number of affected rows

delete

long delete(com.mysema.query.sql.RelationalPath<?> entity,
            SqlDeleteCallback callback)
Execute a database delete using the provided SqlDeleteCallback.

Parameters:
entity - RelationalPath representing the table for the entity
callback - the SqlDeleteCallback implementation that operates on the SQLDeleteClause
Returns:
number of affected rows

Spring Data JDBC Extensions