@ -46,6 +55,7 @@ public class PartTreeJdbcQuery extends AbstractJdbcQuery {
@@ -46,6 +55,7 @@ public class PartTreeJdbcQuery extends AbstractJdbcQuery {
privatefinalJdbcConverterconverter;
privatefinalPartTreetree;
privatefinalJdbcQueryExecution<?>execution;
privatefinalRowMapper<Object>rowMapper;
/**
*Createsanew{@linkPartTreeJdbcQuery}.
@ -77,7 +87,9 @@ public class PartTreeJdbcQuery extends AbstractJdbcQuery {
@@ -77,7 +87,9 @@ public class PartTreeJdbcQuery extends AbstractJdbcQuery {
@ -93,15 +105,108 @@ public class PartTreeJdbcQuery extends AbstractJdbcQuery {
@@ -93,15 +105,108 @@ public class PartTreeJdbcQuery extends AbstractJdbcQuery {
@ -73,6 +73,16 @@ public class StringBasedJdbcQuery extends AbstractJdbcQuery {
@@ -73,6 +73,16 @@ public class StringBasedJdbcQuery extends AbstractJdbcQuery {
this.queryMethod=queryMethod;
this.converter=converter;
if(queryMethod.isSliceQuery()){
thrownewUnsupportedOperationException(
"Slice queries are not supported using string-based queries. Offending method: "+queryMethod);
}
if(queryMethod.isPageQuery()){
thrownewUnsupportedOperationException(
"Page queries are not supported using string-based queries. Offending method: "+queryMethod);
@ -55,7 +57,8 @@ public class JdbcRepositoryCrossAggregateHsqlIntegrationTests {
@@ -55,7 +57,8 @@ public class JdbcRepositoryCrossAggregateHsqlIntegrationTests {
@ -141,7 +143,8 @@ public class JdbcRepositoryIdGenerationIntegrationTests {
@@ -141,7 +143,8 @@ public class JdbcRepositoryIdGenerationIntegrationTests {
@ -63,7 +65,8 @@ public class StringBasedJdbcQueryMappingConfigurationIntegrationTests {
@@ -63,7 +65,8 @@ public class StringBasedJdbcQueryMappingConfigurationIntegrationTests {
Person findByFirstnameAndLastname(String firstname, String lastname); <5>
Person findFirstByLastname(String lastname); <6>
@Query("SELECT * FROM person WHERE lastname = :lastname")
List<Person> findByLastname(String lastname); <5>
List<Person> findByLastname(String lastname); <7>
}
----
<1> The method shows a query for all people with the given `lastname`.
The query is derived by parsing the method name for constraints that can be concatenated with `And` and `Or`.
Thus, the method name results in a query expression of `SELECT … FROM person WHERE firstname = :firstname`.
<2> Use `Pageable` to pass offset and sorting parameters to the database.
<3> Find a single entity for the given criteria.
<3> Return a `Slice<Person>`. Selects `LIMIT+1` rows to determine whether there's more data to consume. `ResultSetExtractor` customization is not supported.
<4> Run a paginated query returning `Page<Person>`. Selects only data within the given page bounds and potentially a count query to determine the total count. `ResultSetExtractor` customization is not supported.
<5> Find a single entity for the given criteria.
It completes with `IncorrectResultSizeDataAccessException` on non-unique results.
<4> In contrast to <3>, the first entity is always emitted even if the query yields more result documents.
<5> The `findByLastname` method shows a query for all people with the given last name.
<6> In contrast to <3>, the first entity is always emitted even if the query yields more result documents.
<7> The `findByLastname` method shows a query for all people with the given last name.
====
The following table shows the keywords that are supported for query methods: