Search in sources :

Example 6 with QUser

use of org.baeldung.querydsl.intro.entities.QUser in project tutorials by eugenp.

the class QueryDSLIntegrationTest method whenRefiningWithSubquery_thenResultCountShouldMatch.

@Test
public void whenRefiningWithSubquery_thenResultCountShouldMatch() {
    QUser user = QUser.user;
    QBlogPost blogPost = QBlogPost.blogPost;
    List<User> users = queryFactory.selectFrom(user).where(user.id.in(JPAExpressions.select(blogPost.user.id).from(blogPost).where(blogPost.title.eq("Hello World!")))).fetch();
    assertEquals(2, users.size());
}
Also used : QUser(org.baeldung.querydsl.intro.entities.QUser) QBlogPost(org.baeldung.querydsl.intro.entities.QBlogPost) QUser(org.baeldung.querydsl.intro.entities.QUser) User(org.baeldung.querydsl.intro.entities.User)

Aggregations

QUser (org.baeldung.querydsl.intro.entities.QUser)6 User (org.baeldung.querydsl.intro.entities.User)4 QBlogPost (org.baeldung.querydsl.intro.entities.QBlogPost)2