Reputation: 2900
For example how can I convert the following JPQL query to QueryDSL?
SELECT p
FROM F f
JOIN f.p p
WHERE index(p)=0
where F.p
is of type List<P>
.
Upvotes: 1
Views: 605
Reputation: 1967
You have to use the get() method in ListPath which implements the index() function.
Just as an example, here is a JPA query (QueryDSL 4.0.6) which gets a catalog entity whose second child category (index 1) has given name:
public Catalog findSecondCatalogChildCategoryByName(String Name) {
return new JPAQueryFactory(entityManager)
.selectFrom(catalog)
.where(
catalog.rootCategories.get(1).name.eq(name)
).fetchOne();
}
Note: In this example, rootCategories field has java.util.List type
Upvotes: 1