[英]Spring JPA entity findBy<Parameter> method giving values in 1st attempt and null in 2nd call?
I have a Spring JPA method to get entity -> findBy<SomeCode>().我有一个 Spring JPA 方法来获取实体 -> findBy<SomeCode>()。 The spring boot application comes up and on making a 1st rest call the entity comes up with all values filled. Spring Boot 应用程序启动并在进行第一次休息调用时,实体出现了所有填充的值。 When tried with 2nd attempt the two entity members coming 'null' which should not be - as other values are there.当尝试第二次尝试时,两个实体成员会出现“null”,这不应该是 - 因为存在其他值。 And there is data in db. db中有数据。
This goes on alternate basis ie if I run again 3rd it comes up filled up while on 4th attempt two entity members again come null.这是在交替的基础上进行的,即如果我再次运行第 3 次,它会被填满,而第 4 次尝试时,两个实体成员再次变为空。
The code log line is as below -代码日志行如下 -
Site site = siteRepo.findByCode(inputSiteCode);
if (site != null) {
log.info("UPDATION CASE");
log.info("site code -> "+ site.getCode()+" lat -> "+ site.getLat() +" lng -> "+ site.getLng() );
My entity piece which is coming null on alternate runs我的实体片在交替运行时为空
@Column(precision = 9, scale = 6)
private BigDecimal lat;
@Column(precision = 9, scale = 6)
private BigDecimal lng;
Repository:存储库:
@Repository
public interface SiteRepository extends JpaRepository<Site, Integer> {
public List<Site> findAll();
public Site findAllById(int id);
public Site findByCode(Integer code);
}
The two logs in 2 calls are as follows: 2次调用中的两次log如下:
Hibernate: select site0_.id as id1_6_, site0_.address as address2_6_, site0_.city as city3_6_, site0_.code as code4_6_, site0_.details as details5_6_, site0_.lat as lat6_6_, site0_.lng as lng7_6_, site0_.name as name8_6_, site0_.scheduler_id as schedule9_6_, site0_.state as state10_6_, site0_.zip as zip11_6_ from mow_site site0_ where site0_.code=?
2022-05-22 21:55:27.931 INFO 44064 --- [cTaskExecutor-5] c.m.d.b.SiteDataProcessor : UPDATION CASE
2022-05-22 21:55:27.931 INFO 44064 --- [cTaskExecutor-5] c.m.d.b.SiteDataProcessor : site code -> 83 lat -> 32.638450 lng -> -97.347690
address -> 7501 JBrown Rd
Hibernate: select site0_.id as id1_6_, site0_.address as address2_6_, site0_.city as city3_6_, site0_.code as code4_6_, site0_.details as details5_6_, site0_.lat as lat6_6_, site0_.lng as lng7_6_, site0_.name as name8_6_, site0_.scheduler_id as schedule9_6_, site0_.state as state10_6_, site0_.zip as zip11_6_ from mow_site site0_ where site0_.code=?
2022-05-22 21:56:57.356 INFO 44064 --- [cTaskExecutor-6] c.m.d.b.SiteDataProcessor : UPDATION CASE
2022-05-22 21:56:57.364 INFO 44064 --- [cTaskExecutor-6] c.m.d.b.SiteDataProcessor : site code -> 83 lat -> null lng -> null
address -> 7501 JBrown Rd
I would appreciate the help.我将不胜感激。 Thanks谢谢
There is no issue in spring jpa find method what I just found out.我刚刚发现的spring jpa find方法没有问题。
It was something written after each successful call which is making the columns null and then when I was trying they came null and refilled again.这是在每次成功调用后编写的内容,这使列变为空,然后当我尝试时,它们变为空并再次重新填充。
I apologise for wasting your time.我为浪费您的时间而道歉。 I will be deleting the post after sometime as this is not at all the issue.我会在一段时间后删除帖子,因为这根本不是问题。
Thanks谢谢
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.