How to combine Left Join Fetch with specification
public interface PersonRepository extends JpaRepository<Person, Integer>, JpaSpecificationExecutor<Person> {
@Lock(LockModeType.PESSIMISTIC_WRITE)
Optional<Person> findWithLockingById(Integer id);
@Query("SELECT p FROM Person p LEFT JOIN FETCH p.positions")
Page<Person> findAll(Specification<Person> spec, Pageable pageable);
}
@Transactional(readOnly = true)
public Page<PersonDto> findAll(Pageable pageable, Map<String, String> params) {
Specification<Person> filter = FilterSpecification.byCriteria(params);
return personRepository.findAll(filter, pageable)
.map(person -> creationStrategies.get(person.getType()).toDto(person));
}
Hello Guys my specification desn't work when I'm filtering. How I can combine specification with @Query - Person class is abstract and base class all others like Studet, Alien etc neet to extend. Problem is only when I'm trying to fetch all people and one of specific person got relationship OneToMany. So I decidet to use LeftJoinFetch - but now my filtering method doesn't work. Thanks3 Replies
⌛
This post has been reserved for your question.
Hey @F4F! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.
Up
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.