Rest API and Hibernate. How to add a new record wi

2019-08-14 05:41发布

I have this object:

public class MerchantDetail {

    private id;
    private boolean optStatus;
    private BigDecimal amountDue;


    @ManyToOne(optional=false) 
    @JoinColumn(referencedColumnName="merchantId") 
    private Merchant merchant;

    //getters and setters
}

My table looks like this:

`MerchantDetail` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`amountdue` decimal(19,2) DEFAULT NULL,
`optstatus` BIT() DEFAULT NULL,
`merchant_merchantId` varchar(255) NOT NULL //autogenerated by hibernate
)

My current codes are using Spring Data JPA using Hibernate.

My Rest API is using Jersey for endpoints and Jackson for marshalling and unmarshalling data.

How am I going to create a new record using JSON?

0条回答
登录 后发表回答