我正在使用 spring data jpa(MYSQL) 开发一个 Spring boot 项目,当我达到这个终点时,http://localhost:8080/admin/interviews/101 我收到此错误{ "timestamp": "2019-10-11T13:45:37.111+0000", "status": 500, "error": "Internal Server Error", "message": "Parameter value [101] did not match expected type [com.yash.arci.model.Interviews (n/a)]; nested exception is java.lang.IllegalArgumentException: Parameter value [101] did not match expected type [com.yash.arci.model.Interviews (n/a)]", "trace": "org.springframework.dao.InvalidDataAccessApiUsageException: Parameter value [101] did not match expected type [com.yash.arci.model.Interviews (n/a)]; nested exception is java.lang.IllegalArgumentException: Parameter value [101] did not match expected type [com.yash.arci.model.Interviews (n/a)]\r\n\tat org.springframework.orm.jpa.EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible这是 InterviewStatus 课程@Entity@Table(name ="interview_status" )public class InterviewStatus implements Serializable {private static final long serialVersionUID = -6353284727527331855L;@Id@GeneratedValue(strategy = GenerationType.AUTO)private Integer id;@ManyToOne(cascade = CascadeType.ALL)@JoinColumn(name ="interviewId",insertable = false, updatable = false)private Interviews interviewId;@ManyToOne(cascade = CascadeType.ALL)@JoinColumn(name ="statusId",insertable = false, updatable = false)private Status statusId;..........}@Repositorypublic interface InterviewStatusRepository extends JpaRepository<InterviewStatus, Integer> {InterviewStatus findByInterviewId(Integer interviewId);}我想要根据 InterviewId 进行记录。我已经可以根据主键获得,但我希望根据 Interview Id 获得它,我在 InterviewStatus 表中有 InterviewId 列。
1 回答

慕姐8265434
TA贡献1813条经验 获得超2个赞
请InterviewStatus findByInterviewId(Interviews interviewId);
在通过运行获取 InterviewId 的地方使用它Interviews findById(Long id)
。
由于数据类型冲突,您可以将预期的数据类型作为参数传入。所以它期望 Interviews 不是 Integer,但你有整数。在这种情况下,您可以使用整数获取 Interviews,然后将获取的 Interviews 作为参数传递。
添加回答
举报
0/150
提交
取消