繁体   English   中英

即使生成的查询在 postgres 控制台中使用时返回结果,JPA 方法也不返回结果

[英]JPA method not returning results even though the generated query returns results when used in postgres console

即使当我记录查询并在数据库控制台上尝试时,我也没有得到 JPA 方法的任何结果,但我得到了正确的结果

回购:

公共接口 FireWeatherDay1CatRiskRepository 扩展

JpaRepository<FireWeatherDay1CatRisk, Long> {
    List<FireWeatherDay1CatRisk> findByAdvTs(Instant advTs);
}

生成的查询:

select fireweathe0_.id as id1_0_,
       fireweathe0_.adv_ts as adv_ts2_0_,
       fireweathe0_.category as category3_0_,
       fireweathe0_."end" as end4_0_,
       fireweathe0_.geom as geom5_0_,
       fireweathe0_.start as start6_0_
from fire_weather_day1_cat_risk fireweathe0_
    where fireweathe0_.adv_ts='2021-09-28T17:00:00Z';

同样,使用 JPA 方法时没有返回结果,但是当我在我的 postgres 控制台中手动运行查询时,生成的查询似乎是正确的,它工作正常。

您没有执行相同的查询。 JPA 执行的是最肯定的

select fireweathe0_.id as id1_0_,
       fireweathe0_.adv_ts as adv_ts2_0_,
       fireweathe0_.category as category3_0_,
       fireweathe0_."end" as end4_0_,
       fireweathe0_.geom as geom5_0_,
       fireweathe0_.start as start6_0_
from fire_weather_day1_cat_risk fireweathe0_
    where fireweathe0_.adv_ts=?;

加上绑定值的值。

问题很可能是瞬间发生了一些转换,可能涉及您的 JVM 或数据库的当前时区。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM