Class CrudRepoBaseQuery<T,Z extends CrudRepository.InlineQuery<T,Z>>
- All Implemented Interfaces:
CrudRepository.InlineQuery<T,
Z>
- Direct Known Subclasses:
BaseValqueriesQuery
,TestDoubleQuery
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected GenericFactory
protected T
protected QueryWrapper
protected TypeDescriber<T>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<X> Stream<X>
Execute the query and return all distinct values of a field that match the query.<X> Z
eq
(BiConsumer<T, X> field, X value) Match if the value of a field equals the specified value.<X> Z
Match if the value of a field equals the specified value.<X extends Comparable<? super X>>
Zgt
(BiConsumer<T, X> field, X value) Match if the value of a field is greater than the specified value.<X extends Comparable<? super X>>
ZMatch if the value of a field is greater than the specified value.<X extends Comparable<? super X>>
Zgte
(BiConsumer<T, X> field, X value) Match if the value of a field is greater than or equal to the specified value.<X extends Comparable<? super X>>
ZMatch if the value of a field is greater than or equal to the specified value.isNull
(BiConsumer<T, ?> field) Match if the value of a field is null.Match if the value of a field is null.<X extends Comparable<? super X>>
Zlt
(BiConsumer<T, X> field, X value) Match if the value of a field is less than the specified value.<X extends Comparable<? super X>>
ZMatch if the value of a field is less than the specified value.<X extends Comparable<? super X>>
Zlte
(BiConsumer<T, X> field, X value) Match if the value of a field is less than or equal to the specified value.<X extends Comparable<? super X>>
ZMatch if the value of a field is less than or equal to the specified value.<X> Z
notEq
(BiConsumer<T, X> field, X value) Match if the value of a field is not equal to the specified value.<X> Z
Match if the value of a field is not equal to the specified value.<X> Stream<X>
selectField
(Function<T, X> field) Execute the query and return all values of a field that match the query.<X extends Comparable<? super X>>
ZsortAscending
(BiConsumer<T, X> field) Sort the results by the given field in ascending order.<X extends Comparable<? super X>>
ZsortAscending
(Function<T, X> field) Sort the results by the given field in ascending order.<X extends Comparable<? super X>>
ZsortDescending
(BiConsumer<T, X> field) Sort the results by the given field in descending order.<X extends Comparable<? super X>>
ZsortDescending
(Function<T, X> field) Sort the results by the given field in descending order.withEager
(BiConsumer<T, ?> field) Causes aRelation
field to be eagerly fetched.Causes aRelation
field to be eagerly fetched.
-
Field Details
-
instance
-
queryWrapper
-
clazz
-
typeDescriber
-
genericFactory
-
-
Constructor Details
-
CrudRepoBaseQuery
-
-
Method Details
-
eq
Description copied from interface:CrudRepository.InlineQuery
Match if the value of a field equals the specified value. If you want to match null values, you have to useCrudRepository.InlineQuery.isNull(Function)
.Example:
query.eq(Person::getName, "Bob")
This will match people with the name "Bob".
- Specified by:
eq
in interfaceCrudRepository.InlineQuery<T,
Z extends CrudRepository.InlineQuery<T, Z>> - Type Parameters:
X
- the type of the field and value- Parameters:
field
- a method reference to the getter of the fieldvalue
- the value to check against- Returns:
- the query, for chaining
-
eq
Description copied from interface:CrudRepository.InlineQuery
Match if the value of a field equals the specified value. If you want to match null values, you have to useCrudRepository.InlineQuery.isNull(BiConsumer)
.Example:
query.eq(Person::setName, "Bob")
This will match people with the name "Bob".
- Specified by:
eq
in interfaceCrudRepository.InlineQuery<T,
Z extends CrudRepository.InlineQuery<T, Z>> - Type Parameters:
X
- the type of the field and value- Parameters:
field
- a method reference to the setter of the fieldvalue
- the value to check against- Returns:
- the query, for chaining
-
notEq
Description copied from interface:CrudRepository.InlineQuery
Match if the value of a field is not equal to the specified value.Example:
query.notEq(Person::getName, "Bob")
This will match people with a name other than "Bob".
- Specified by:
notEq
in interfaceCrudRepository.InlineQuery<T,
Z extends CrudRepository.InlineQuery<T, Z>> - Type Parameters:
X
- the type of the field and value- Parameters:
field
- a method reference to the getter of the fieldvalue
- the value to check against- Returns:
- the query, for chaining
-
notEq
Description copied from interface:CrudRepository.InlineQuery
Match if the value of a field is not equal to the specified value.Example:
query.notEq(Person::setName, "Bob")
This will match people with a name other than "Bob".
- Specified by:
notEq
in interfaceCrudRepository.InlineQuery<T,
Z extends CrudRepository.InlineQuery<T, Z>> - Type Parameters:
X
- the type of the field and value- Parameters:
field
- a method reference to the setter of the fieldvalue
- the value to check against- Returns:
- the query, for chaining
-
gt
Description copied from interface:CrudRepository.InlineQuery
Match if the value of a field is greater than the specified value.Example:
query.gt(Person::getAge, 18)
This will match people older than 18.
- Specified by:
gt
in interfaceCrudRepository.InlineQuery<T,
Z extends CrudRepository.InlineQuery<T, Z>> - Type Parameters:
X
- the type of the field and value- Parameters:
field
- a method reference to the getter of the fieldvalue
- the value to check against- Returns:
- the query, for chaining
-
gt
Description copied from interface:CrudRepository.InlineQuery
Match if the value of a field is greater than the specified value.Example:
query.gt(Person::setAge, 18)
This will match people older than 18.
- Specified by:
gt
in interfaceCrudRepository.InlineQuery<T,
Z extends CrudRepository.InlineQuery<T, Z>> - Type Parameters:
X
- the type of the field and value- Parameters:
field
- a method reference to the setter of the fieldvalue
- the value to check against- Returns:
- the query, for chaining
-
gte
Description copied from interface:CrudRepository.InlineQuery
Match if the value of a field is greater than or equal to the specified value.Example:
query.gte(Person::getAge, 18)
This will match people that are 18 or older.
- Specified by:
gte
in interfaceCrudRepository.InlineQuery<T,
Z extends CrudRepository.InlineQuery<T, Z>> - Type Parameters:
X
- the type of the field and value- Parameters:
field
- a method reference to the getter of the fieldvalue
- the value to check against- Returns:
- the query, for chaining
-
gte
Description copied from interface:CrudRepository.InlineQuery
Match if the value of a field is greater than or equal to the specified value.Example:
query.gte(Person::setAge, 18)
This will match people that are 18 or older.
- Specified by:
gte
in interfaceCrudRepository.InlineQuery<T,
Z extends CrudRepository.InlineQuery<T, Z>> - Type Parameters:
X
- the type of the field and value- Parameters:
field
- a method reference to the setter of the fieldvalue
- the value to check against- Returns:
- the query, for chaining
-
lt
Description copied from interface:CrudRepository.InlineQuery
Match if the value of a field is less than the specified value.Example:
query.lt(Person::getAge, 18)
This will match people younger than 18.
- Specified by:
lt
in interfaceCrudRepository.InlineQuery<T,
Z extends CrudRepository.InlineQuery<T, Z>> - Type Parameters:
X
- the type of the field and value- Parameters:
field
- a method reference to the getter of the fieldvalue
- the value to check against- Returns:
- the query, for chaining
-
lt
Description copied from interface:CrudRepository.InlineQuery
Match if the value of a field is less than the specified value.Example:
query.lt(Person::setAge, 18)
This will match people younger than 18.
- Specified by:
lt
in interfaceCrudRepository.InlineQuery<T,
Z extends CrudRepository.InlineQuery<T, Z>> - Type Parameters:
X
- the type of the field and value- Parameters:
field
- a method reference to the setter of the fieldvalue
- the value to check against- Returns:
- the query, for chaining
-
lte
Description copied from interface:CrudRepository.InlineQuery
Match if the value of a field is less than or equal to the specified value.Example:
query.lte(Person::getAge, 18)
This will match people that are 18 or younger.
- Specified by:
lte
in interfaceCrudRepository.InlineQuery<T,
Z extends CrudRepository.InlineQuery<T, Z>> - Type Parameters:
X
- the type of the field and value- Parameters:
field
- a method reference to the getter of the fieldvalue
- the value to check against- Returns:
- the query, for chaining
-
lte
Description copied from interface:CrudRepository.InlineQuery
Match if the value of a field is less than or equal to the specified value.Example:
query.lte(Person::setAge, 18)
This will match people that are 18 or younger.
- Specified by:
lte
in interfaceCrudRepository.InlineQuery<T,
Z extends CrudRepository.InlineQuery<T, Z>> - Type Parameters:
X
- the type of the field and value- Parameters:
field
- a method reference to the setter of the fieldvalue
- the value to check against- Returns:
- the query, for chaining
-
isNull
Description copied from interface:CrudRepository.InlineQuery
Match if the value of a field is null.Example:
query.isNull(Person::getEmail)
This will match people whose email is null.
Note: if the model class has fields of primitive type, they won't be null, even if the database contains NULL values. In this case isNull will still match correctly based on the values in the database.
- Specified by:
isNull
in interfaceCrudRepository.InlineQuery<T,
Z extends CrudRepository.InlineQuery<T, Z>> - Parameters:
field
- a method reference to the getter of the field- Returns:
- the query, for chaining
-
isNull
Description copied from interface:CrudRepository.InlineQuery
Match if the value of a field is null.Example:
query.isNull(Person::setEmail)
This will match people whose email is null.
Note: if the model class has fields of primitive type, they won't be null, even if the database contains NULL values. In this case isNull will still match correctly based on the values in the database.
- Specified by:
isNull
in interfaceCrudRepository.InlineQuery<T,
Z extends CrudRepository.InlineQuery<T, Z>> - Parameters:
field
- a method reference to the setter of the field- Returns:
- the query, for chaining
-
sortAscending
Description copied from interface:CrudRepository.InlineQuery
Sort the results by the given field in ascending order.Example:
query.sortAscending(Person::getAge)
This will sort the results by age in ascending order.
- Specified by:
sortAscending
in interfaceCrudRepository.InlineQuery<T,
Z extends CrudRepository.InlineQuery<T, Z>> - Type Parameters:
X
- the type of the field- Parameters:
field
- a method reference to the getter of the field- Returns:
- the query, for chaining
-
sortAscending
Description copied from interface:CrudRepository.InlineQuery
Sort the results by the given field in ascending order.Meant to be used with a setter method reference.
Example:
query.sortAscending(Person::setAge)
This will sort the results by age in ascending order.
- Specified by:
sortAscending
in interfaceCrudRepository.InlineQuery<T,
Z extends CrudRepository.InlineQuery<T, Z>> - Type Parameters:
X
- the type of the field- Parameters:
field
- a method reference to the setter of the field- Returns:
- the query, for chaining
-
sortDescending
Description copied from interface:CrudRepository.InlineQuery
Sort the results by the given field in descending order.Example:
query.sortDescending(Person::getAge)
This will sort the results by age in descending order.
- Specified by:
sortDescending
in interfaceCrudRepository.InlineQuery<T,
Z extends CrudRepository.InlineQuery<T, Z>> - Type Parameters:
X
- the type of the field- Parameters:
field
- a method reference to the getter of the field- Returns:
- the query, for chaining
-
sortDescending
Description copied from interface:CrudRepository.InlineQuery
Sort the results by the given field in descending order.Meant to be used with a setter method reference.
Example:
query.sortDescending(Person::setAge)
This will sort the results by age in descending order.
- Specified by:
sortDescending
in interfaceCrudRepository.InlineQuery<T,
Z extends CrudRepository.InlineQuery<T, Z>> - Type Parameters:
X
- the type of the field- Parameters:
field
- a method reference to the setter of the field- Returns:
- the query, for chaining
-
withEager
Description copied from interface:CrudRepository.InlineQuery
Causes aRelation
field to be eagerly fetched. Useful to avoid multiple queries if you know that you will access the relation.Eagerness is defined by the implementation, but it generally means that the field will be fetched in the same query as the parent object, rather than in a separate query when the field is accessed (lazy loading).
Example, returning a stream of all phones of people that are 18:
query.eq(Person::getAge, 18).withEager(Person::getPhone).execute().map(Person::getPhone)
This will result in one query to the database, instead of creating a separate query to get each phone.
- Specified by:
withEager
in interfaceCrudRepository.InlineQuery<T,
Z extends CrudRepository.InlineQuery<T, Z>> - Parameters:
field
- a method reference to the getter of the field- Returns:
- the query, for chaining
-
withEager
Description copied from interface:CrudRepository.InlineQuery
Causes aRelation
field to be eagerly fetched. Useful to avoid multiple queries if you know that you will access the relation.Eagerness is defined by the implementation, but it generally means that the field will be fetched in the same query as the parent object, rather than in a separate query when the field is accessed (lazy loading).
Example, returning a stream of all phones of people that are 18:
query.eq(Person::setAge, 18).withEager(Person::getPhone).execute().map(Person::getPhone)
This will result in one query to the database, instead of creating a separate query to get each phone.
- Specified by:
withEager
in interfaceCrudRepository.InlineQuery<T,
Z extends CrudRepository.InlineQuery<T, Z>> - Parameters:
field
- a method reference to the setter of the field- Returns:
- the query, for chaining
-
distinct
Description copied from interface:CrudRepository.InlineQuery
Execute the query and return all distinct values of a field that match the query.This is useful if you need just a single field from an object, as it will only transfer that column over the network and will only deserialize that field.
Sorting can be used, but only on the same column that is being selected.
This is a terminal operation. As such, the query should not be reused after this method is called.
The resulting
Stream
from the operation may be a lazy stream, meaning that the results are not fetched from the database until they are accessed. As such it is important that a terminal operation is performed on the stream within a reasonable time frame to avoid holding database connections open.- Specified by:
distinct
in interfaceCrudRepository.InlineQuery<T,
Z extends CrudRepository.InlineQuery<T, Z>> - Type Parameters:
X
- the type of the field- Parameters:
field
- a method reference to the getter of the field- Returns:
- a
Stream
of distinct values of the field
-
selectField
Description copied from interface:CrudRepository.InlineQuery
Execute the query and return all values of a field that match the query.This is useful if you need just a single field from an object, as it will only transfer that column over the network and will only deserialize that field.
This is a terminal operation. As such, the query should not be reused after this method is called.
The resulting
Stream
from the operation may be a lazy stream, meaning that the results are not fetched from the database until they are accessed. As such it is important that a terminal operation is performed on the stream within a reasonable time frame to avoid holding database connections open.- Specified by:
selectField
in interfaceCrudRepository.InlineQuery<T,
Z extends CrudRepository.InlineQuery<T, Z>> - Type Parameters:
X
- the type of the field- Parameters:
field
- a method reference to the getter of the field- Returns:
- a
Stream
of values of the field
-