Open spring-projects-issues opened 8 years ago
Oliver Drotbohm commented
What exactly are you missing in QueryDslRepositorySupport
? It basically allows you to call from(SiteAccessRequest.class).where( SiteAccessRequestExpressions.byExample(criteria))…
and by that move that logic into the repository layer if desired
Andrei Ivanov commented
Well, at least QueryDslJpaRepository.findAll(Predicate predicate, Pageable pageable)
content I would have to copy/paste in my own method.
Then from(SiteAccessRequest.class)
doesn't seem to work, as QueryDslRepositorySupport.from
expects an EntityPath
(I see these are created in the constructor of QueryDslJpaRepository
)
Oliver Drotbohm commented
My mistake, I am not near any IDE right now. I guess it expects a Querydsl root path then. Something from the meta-model it generates, like QUser.user or the like.
So it boils down to the lack of application of Pageable
?
Andrei Ivanov commented
At least for what I'm doing now, I think so. Even for a simple query I think it would be nice to get an example in the documentation about this combination of custom repository and Querydsl
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Andrei Ivanov opened DATACMNS-898 and commented
Hi, As far as I understand from the documentation, working with Querydsl in a repository means that the repository interface should extend
QueryDslPredicateExecutor
:This seems a bit weird to me because now the "query" gets created in the service/facade layer:
And this also make integration testing difficult, as this is similar to having a method like
findAll(String sql)
defined in the repository interface.So I tried to create a custom repository for this:
This is were I got stuck. When using the
QueryDslPredicateExecutor
, thefindAll(Predicate predicate, Pageable pageable)
method is handled byQueryDslJpaRepository
. ButQueryDslRepositorySupport
has only some basic methods to perform queries. What I am suggesting is to move some of the methods fromQueryDslJpaRepository
toQueryDslPredicateExecutor
to make this case easier to implement.Or maybe there already is a better way to implement custom repositories with Querydsl that I haven't seen?
Affects: 1.12.2 (Hopper SR2)