我想通过jpa查询获取我的对象列表,我使用以下代码:
@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);但我有个例外:
unexpected token: vz"有什么问题吗?
发布于 2021-09-01 07:30:19
字符串文本的末尾有一些遗漏的空格。例如,在concat之后,结果类似于"...from VzClass vzjoin vz.PHClass.“。它应该看起来像
@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) ")发布于 2021-09-01 07:32:49
您需要使用行尾或空格来逃避,如下所示:
@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);https://stackoverflow.com/questions/69009455
复制相似问题