0

I am facing issues while making a POST request to a Spring data rest endpoint. My entity contains a foreign key to another entity. Testing this endpoint from rest client works fine but when I am using Rest Template or Feign Client, the foreign key field is inserted as null while other data goes well. I am using Spring Boot Version : 1.3.5.RELEASE Entities are exposed through Spring Data JPA and Data rest.

Please help.

public class Question{

/** The question id. */
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "question_id")
private Integer questionId;

/** The question. */
private String question;

/** The question type. */
@ManyToOne
@JoinColumn(name = "question_type")
private QuestionType questionType;
}


public class QuestionType{

/** The question type id. */
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "question_type_id")
private Integer questionTypeId;

private String name;
}


public interface QuestionRepository extends JpaRepository<Question,Integer>{}
ankur agrawal
  • 294
  • 2
  • 8

0 Answers0