Reputation:
I want to get List of my objects by jpa query I'm using this code:
@Query("select vz from VzClass vz" +
"join vz.PHClass phc on vz.ph = phc.id" +
"join phc.GFClass gf on phc.id = gf.phouse" +
"join gf.PIClass pi on gf.pic = pi.id" +
"where vz.fi is not null and vz.ci is null and pi.prId in (:pIds)")
List<VzClass> getVzByPIids(@Param("pIds") List<String> plIds, Pageable pageable);
But I get the exception:
unexpected token: vz"
What is the problem there?
Upvotes: 2
Views: 82
Reputation: 235
You need to escape with an end of line or space like so:
@Query("select vz from VzClass vz\n" +
"join vz.PHClass phc on vz.ph = phc.id\n" +
"join phc.GFClass gf on phc.id = gf.phouse\n" +
"join gf.PIClass pi on gf.pic = pi.id\n" +
"where vz.fi is not null and vz.ci is null and pi.prId in (:pIds)")
List<VzClass> getVzByPIids(@Param("pIds") List<String> plIds, Pageable pageable);
Upvotes: 0
Reputation: 4382
There are some missing spaces at the end of string literals. For example after concat the result is like "...from VzClass vzjoin vz.PHClass...". It should look like
@Query("select vz from VzClass vz " +
"join vz.PHClass phc on vz.ph = phc.id " +
"join phc.GFClass gf on phc.id = gf.phouse " +
"join gf.PIClass pi on gf.pic = pi.id " +
"where vz.fi is not null and vz.ci is null and pi.prId in (:pIds) ")
Upvotes: 2