I am unable to perform CRUD via json POST from restful client Postman on Composite table having extra column .I am using Spring boot ,spring data rest and spring JPA. I hav
Apparently there seems to be no "natural/easy" way to get what you want. But there is a promissing project for integrating embeddables by extending the serialization process: https://github.com/gregturn/embeddable-spring-data-rest
UserCompetencyIdJacksonModule
, UserCompetencyIdSerializer
, ..Then you should be able PATCH (not POST) your JSON from above.
With this code I was able to post a new relation:
UserCompetency.class
@Entity
@Table(name = "user_competency")
@IdClass(UserCompetencyId.class)
public class UserCompetency implements java.io.Serializable {
@Id @ManyToOne
@JoinColumn(name = "competency_id", nullable = false, insertable = false, updatable = false)
private Competency competency;
@Id @ManyToOne
@JoinColumn(name = "user_id", nullable = false, insertable = false, updatable = false)
private User user;
UserCompetencyId.class
public class UserCompetencyId implements java.io.Serializable {
private Long competency;
private Long user;
public UserCompetencyId() {
}
public UserCompetencyId(Long competency, Long user) {
this.competency = competency;
this.user = user;
}
UserCompetencyRepository.class
public interface UserCompetencyRepository extends JpaRepository<UserCompetency, UserCompetencyId> {
}
POST http://localhost:8080/userCompetencies
{
"competency": "/competencies/2"
, "user": "/user/4"
}