Skip to content
Advertisement

Exception with JPA Query Spring

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?

Advertisement

Answer

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) ")
Advertisement