How to write a predicate for QueryDslPredicateExecutor

When I try to use Querydsl, as shown in Spring, the Spring link is 1.10.4. Help link - I get some errors from the IDE: Cannot resolve findAll (predicate) method. I changed the import to com.mysema.query.types.Predicate. Now the method looks great. But I can not solve the problem with:

Predicate predicate = user.getUsername().equalsIgnoreCase(username).and((user.getId().equals(userid)).not);

I got errors: cannot resolve method: and cannot resolve method not.

Some of the links: Example 32. Integrating Querydsl in repositories

interface UserRepository extends CrudRepository<User, Long>, QueryDslPredicateExecutor<User> {

}

The above allows you to write query types using Querydsl Predicate s.

Predicate predicate = user.firstname.equalsIgnoreCase("dave")
.and(user.lastname.startsWithIgnoreCase("mathews"));

userRepository.findAll(predicate);

But the example is incorrect. Does anyone know how to use this?

+4

Source: https://habr.com/ru/post/1660944/


All Articles