Search in sources :

Example 1 with QPerson

use of org.baeldung.entity.QPerson in project tutorials by eugenp.

the class PersonDaoImpl method findPersonsByFirstnameAndSurnameQueryDSL.

@Override
public List<Person> findPersonsByFirstnameAndSurnameQueryDSL(final String firstname, final String surname) {
    final JPAQuery<Person> query = new JPAQuery<>(em);
    final QPerson person = QPerson.person;
    return query.from(person).where(person.firstname.eq(firstname).and(person.surname.eq(surname))).fetch();
}
Also used : QPerson(org.baeldung.entity.QPerson) Person(org.baeldung.entity.Person) QPerson(org.baeldung.entity.QPerson) JPAQuery(com.querydsl.jpa.impl.JPAQuery)

Example 2 with QPerson

use of org.baeldung.entity.QPerson in project tutorials by eugenp.

the class PersonDaoImpl method findPersonsByFirstnameInDescendingOrderQueryDSL.

@Override
public List<Person> findPersonsByFirstnameInDescendingOrderQueryDSL(final String firstname) {
    final JPAQuery<Person> query = new JPAQuery<>(em);
    final QPerson person = QPerson.person;
    return query.from(person).where(person.firstname.eq(firstname)).orderBy(person.surname.desc()).fetch();
}
Also used : QPerson(org.baeldung.entity.QPerson) Person(org.baeldung.entity.Person) QPerson(org.baeldung.entity.QPerson) JPAQuery(com.querydsl.jpa.impl.JPAQuery)

Example 3 with QPerson

use of org.baeldung.entity.QPerson in project tutorials by eugenp.

the class PersonDaoImpl method findMaxAge.

@Override
public int findMaxAge() {
    final JPAQuery<Person> query = new JPAQuery<>(em);
    final QPerson person = QPerson.person;
    return query.from(person).select(person.age.max()).fetchFirst();
}
Also used : QPerson(org.baeldung.entity.QPerson) Person(org.baeldung.entity.Person) QPerson(org.baeldung.entity.QPerson) JPAQuery(com.querydsl.jpa.impl.JPAQuery)

Example 4 with QPerson

use of org.baeldung.entity.QPerson in project tutorials by eugenp.

the class PersonDaoImpl method findPersonsByFirstnameQueryDSL.

@Override
public List<Person> findPersonsByFirstnameQueryDSL(final String firstname) {
    final JPAQuery<Person> query = new JPAQuery<>(em);
    final QPerson person = QPerson.person;
    return query.from(person).where(person.firstname.eq(firstname)).fetch();
}
Also used : QPerson(org.baeldung.entity.QPerson) Person(org.baeldung.entity.Person) QPerson(org.baeldung.entity.QPerson) JPAQuery(com.querydsl.jpa.impl.JPAQuery)

Example 5 with QPerson

use of org.baeldung.entity.QPerson in project tutorials by eugenp.

the class PersonDaoImpl method findMaxAgeByName.

@Override
public Map<String, Integer> findMaxAgeByName() {
    final JPAQuery<Person> query = new JPAQuery<>(em);
    final QPerson person = QPerson.person;
    return query.from(person).transform(GroupBy.groupBy(person.firstname).as(GroupBy.max(person.age)));
}
Also used : QPerson(org.baeldung.entity.QPerson) Person(org.baeldung.entity.Person) QPerson(org.baeldung.entity.QPerson) JPAQuery(com.querydsl.jpa.impl.JPAQuery)

Aggregations

JPAQuery (com.querydsl.jpa.impl.JPAQuery)5 Person (org.baeldung.entity.Person)5 QPerson (org.baeldung.entity.QPerson)5