Issue
I use JPA with hibernate. I want to check that row with specified name and username exists. The following query raises an error:
@Query("select exists (select 1 from Strategy s where s.name=:name and s.username=:username)")
Boolean exists2(@Param("name") String name,@Param("username") String username);
Error:
Caused by: org.hibernate.hql.ast.QuerySyntaxException: unexpected end of subtree [select exists (select s from com.soft.domain.strategy.Strategy s where s.name=:name and s.username=:username)]
Any ideas?
Solution
I solved this problem by switching query on the following:
@Query("select count(s) from Strategy s where s.name=:name and s.username=:username")
long exists2(@Param("name") String name, @Param("username") String username);
Answered By - Mariusz
Answer Checked By - Mary Flores (JavaFixing Volunteer)