Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Spring boot rest service duplicated response body

I’m using Spring Boot framework and my response returns duplicated with reversed backward.
I’m asking for advices, how can i solve this situation?

Controller End Point

@GetMapping("/getPDetailsW/{W}")
public PPreviewW getPDetailsPreviewW(@PathVariable String W) {

   DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss");
   LocalDateTime now = LocalDateTime.now();
   String nullCheckBill = "bos";
   PPreviewW response = new PromoPreviewWGsm();

   PPreviewInfo pPreviewInfo = listRepository.findPByW(W);
   log.info(dtf.format(now) + "|getPDetailsPreviewW|" + W+ "|için istek atıldı.");

   response.setDisplayId(pPreviewInfo.getDISPLAY_ID());
   response.setAccountCode(pPreviewInfo.getACCOUNT_CODE());

   if (pPreviewInfo.W!= "bos") {
       nullCheckBill = promoPreviewInfo.W;
   }

   if (nullCheckBill == "bos") {
       response.setNEXTFLAG(Boolean.FALSE);
   } else {
       response.setNEXTFLAG(Boolean.TRUE);
   }
   return response;
}

I have @RestController annotation at top of my Controller class.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

PPreviewW response class

@Getter
@Setter
public class PPreviewW implements Serializable {

    public String DisplayId;
    public String AccountCode;
}

I’m using lombok getters and setters

Repository Class

public PPreviewInfo findPByW(String W) {
    PPreviewInfo list = jdbcTemplate
            .queryForObject(QueryConstants.GET_P_PREVIEW_INFOW, new Object[]{W}, new PPreviewInfoMapper());

    return list;
}

@Repository and @Autowired annotations at top of Repository class.
and QueryContants includes my sql which returns correct size for example like XXXX and YYYY
PPreviewInfo Class

@Getter
@Setter
public class PPreviewInfo {

    public String CUSTOMER_ID;
    public String BILLING_ACCOUNT_CODE;
}

PPreviewInfoMapper Class

public class PPreviewInfoMapper implements RowMapper<PPreviewInfo> {
    @Override
    public PPreviewInfo mapRow(ResultSet rs, int i) throws SQLException {

        PPreviewInfo pbn = new PPreviewInfo();

        pbn.setDISPLAY_ID(rs.getString("DISPLAY_ID"));
        pbn.setACCOUNT_CODE(rs.getString("ACCOUNT_CODE"));
        return pbn;
    }
}

response

{"DisplayId":"XXXX","AccountCode":"YYYYYY","NEXTFLAG":true,"nextflag":true,"displayId":"XXXX","accountCode":"YYYYYY"}

>Solution :

The visibility of the attributes might be causing the issue, you can see if changing them to private might help in resolution:

@Getter
@Setter
public class PPreviewW implements Serializable {

    private String DisplayId;
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading