I'm trying to search for posts that have their strategy in the provided list, but every time it returns an empty list.
I thought that maybe some parameters were invalid, but debug mode shows that everything is just as it should be.
Then I tried using regular SQL from console to check if maybe the construction of HQL was invalid, but it returned all posts just fine.
I'm out of ideas; it must be something that I'm doing wrong with hibernate, but I can't tell what.
Method:
@Transactional
public List<Post> getPostsWithoutQuery(List<String> allowedStrategyList, int page, int resultsPerPage) {
return entityManager.createQuery("from Post post where post.postStrategy in (:postStrategyList)", Post.class)
.setParameter("postStrategyList", allowedStrategyList)
.setFirstResult((page - 1) * resultsPerPage)
.setMaxResults(resultsPerPage)
.getResultList();
}
Regular SQL:
select * from post p where p.post_strategy in ('ImagePostStrategy', 'VideoPostStrategy', 'StoryPostStrategy')