Questions tagged [query-by-example]
97 questions
20
votes
4 answers
Spring Boot & JPA: Implementing search queries with optional, ranged criteria
This is an SSCCE, shows research, isn't a dupe and is on topic!!!
Spring Boot REST service and MySQL here. I have the following Profile entity:
@Entity
@Table(name = "profiles")
public class Profile extends BaseEntity {
@Id
…

smeeb
- 27,777
- 57
- 250
- 447
13
votes
1 answer
Spring Data ExampleMatchers by Example
I'm trying to understand how to use Spring Data's Query by Example capabilities, and am struggling to understand how to use ExampleMatcher and its various with* methods. Classic examples of the matcher in use includes snippets like this:
Person…

smeeb
- 27,777
- 57
- 250
- 447
11
votes
2 answers
Spring JPA ExampleMatcher compare date condition
I'm using Spring JPA and get list of data by using Example Matcher.
Source code below:
public Page findAllByConditions(TranxReportFormModel formModel, Pageable page) {
ExampleMatcher matcher = ExampleMatcher.matching()
…

Tran Tam
- 699
- 3
- 14
- 27
11
votes
2 answers
Use cases of methods of QueryByExampleExecutor interface in Spring data JPA
What are the use cases of the methods of this interface QueryByExampleExecutor in Spring data JPA. I have googled and found nothing more than the official documentation.
Perhaps someone can point me to the right resource with examples.
In…

inginia
- 412
- 1
- 6
- 15
8
votes
1 answer
How to make ExampleMatcher to match just one property?
How to implement ExampleMatcher, to match just one property randomly from my class and ignore the other properties?
Assume my class like this :
Public Class Teacher() {
String id;
String name;
String address;
String phone;
int…

Jigu Jigu
- 145
- 1
- 10
8
votes
1 answer
Dealing with numbers using Spring ExampleMatcher
I am new to Java and Spring, and I am building a sytem using Spring JPA. I am now working on my service and controller classes, and I would like to create a dynamic query. I have created a form, in which the user can enter values in the fields, or…

Guillaume
- 357
- 4
- 10
8
votes
3 answers
Hive lateral view with sample example with hive table having 1 column as array
My use case is I am having one table in hive which has one column as INT and one as Array data type. I want to display it horizontally..

Nakul Dev
- 81
- 1
- 1
- 4
7
votes
2 answers
Does Dapper support strongly typed objects with a stored procedure?
Basically, I want to use the "nice" Dapper syntax for a stored procedure, without having to manually use exec MySproc @p1, @p2, @p3, @p4 and so on, but I need to be able to pass in a strongly typed object with various properties set and have this…

Wayne Molina
- 19,158
- 26
- 98
- 163
6
votes
3 answers
Query by Example on associations
It's very frustrating that you cannot use QBE on associations.
I have a large datatable with about 8 many-to-one columns. There is a a drop-down list for every column to filter the table.
Let's assume the following:
Table User
User { id, UserStatus,…

rotsch
- 1,909
- 16
- 36
6
votes
1 answer
Query by Example Spring Data - In Clause?
As per Spring Docs, I can write exact matching only for QBE.
I need exact matching only but among a set of values (IN clause of query).
e.g.
Person p = new Person();
p.setId(); // need to match among set of ids.
Example.of(p);
Is this somehow…

Sachin Sharma
- 1,446
- 4
- 18
- 37
6
votes
1 answer
Spring queryByExample with Range between
I have Spring Application with a repository
interface EventRepository extends JpaRepository, QueryByExampleExecutor { }
Event e = new Event();
e.setTest('ABC');
eventRepository.findAll(Example.of(e), pageable);
Is working…

Pascal
- 2,059
- 3
- 31
- 52
5
votes
1 answer
NHibernate Criteria QueryByExample stuck with SQL in the middle
I am using Criteria to speed up a query, and I am almost there.
Using Query By Example to match up rows in a table, remove duplicate rows with the same id, and then paginate.
Of course I can't paginate until I remove the duplicate rows, and I don't…

zeristor
- 429
- 6
- 22
4
votes
1 answer
Hibernate: Query By Example equivalent of association Criteria Query
I'd like to search my data source for all object instances based on the values of an object related by association. The data model can be simplified to: object of type A holds a list of objects of type B. The goal is to find all instances of A where…

filip-fku
- 3,265
- 1
- 21
- 19
4
votes
1 answer
Spring Data: Query By Example and Converter
I have an entity:
import javax.persistence.Convert;
@Entity(name = "my_entity")
public class MyEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String name;
@Convert(converter =…

mkczyk
- 2,460
- 2
- 25
- 40
4
votes
1 answer
Spring Jpa Query by Example collection
Let's say I have an entity
public class Person {
private String id;
private String firstname;
private String lastname;
private Set ownedCars;
}
Is there a way I can use query by example to find any person named James having…

Matúš Zábojník
- 1,084
- 1
- 10
- 20