Springboot Jpa column position twisted

Viewed 62

I having trouble with netPrice, publishStatus column in Product table. I'm trying to update product table, but input goes wrong way. (PUT netPrice(input) -> publishStatus(output)), (PUT publishStatus(input) -> netPrice(output)). I think tables are twisted.

 @Transactional
    public String update(String productNumber, ProductUpdateRequestDto requestDto){
        Product product = productRepository.findByProductNumber(productNumber);

        product.update(requestDto.getProductName(),
                product.getProductNumber(),
                requestDto.getStockQuantity(),
                requestDto.getDescription(),
                requestDto.getCategoryId() ,
                requestDto.getPublishStatus(),
                requestDto.getNetPrice(),  requestDto.getUnit());
        return productNumber;
@Getter
@NoArgsConstructor
public class ProductUpdateRequestDto {
    private String productName;
    private String productNumber;
    private int stockQuantity;
    private String description;
    private Long categoryId;
    private int publishStatus;
    private int netPrice;
    private String unit;

    @Builder
    public ProductUpdateRequestDto(String productName, String productNumber, int stockQuantity, String description, Long categoryId, int publishStatus, int netPrice, String unit){
        this.productName = productName;
        this.productNumber =productNumber;
        this.stockQuantity = stockQuantity;
        this.description = description;
        this.categoryId = categoryId;
        this.netPrice = netPrice;
        this.publishStatus = publishStatus;
        this.unit = unit;
    }

if you need more info to understand my question. I will update it!

    @Builder
    public void update(String productName, String productNumber, int stockQuantity, String description, Long categoryId, int netPrice, int publishStatus, String unit){
        this.productName = productName;
        this.productNumber = productNumber;
        this.stockQuantity = stockQuantity;
        this.description = description;
        this.categoryId = categoryId;
        this.netPrice = netPrice;
        this.publishStatus = publishStatus;
        this.unit = unit;
1 Answers

Could you please share product.update(...) method.

I can see the order of properties does not match in your ProductUpdateRequestDto wrt product.update(...) call

Related