[英]Spring boot JPA Query
Hi i am writing the Query in Spring boot and I have some doubts on it.嗨,我正在 Spring 启动中编写查询,我对此有一些疑问。
let me share you the POJO class details.让我与您分享 POJO class 的详细信息。
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer studentId;
private String studentName;
@Enumerated(EnumType.STRING)
private Gender gender;
private String schoolName;
@OneToOne(cascade = {CascadeType.ALL})
private AddressID addressID;
@Enumerated(EnumType.STRING)
private BoardId boardId;
private Boolean active;
@OneToOne(cascade = {CascadeType.ALL})
private AcademicId academicid;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer academicId;
private String acadamicYear;
@Enumerated(EnumType.STRING)
private Medium medium;
@OneToOne(cascade = {CascadeType.ALL})
private SubjectId subjectId;
@Enumerated(EnumType.STRING)
private Standard standard;
@Enumerated(EnumType.STRING)
private Term term;
public enum Term {
MIDTERM,QUATERLY,HALFEARLY,ANNUAL;
}
public enum Medium {
TAMIL, ENGLISH,OTHERS;
}
If I want the write a query to filter based on Year, Term and StudentID如果我想编写一个查询来根据年份、学期和学生 ID 进行过滤
Currently I have written like this.目前我是这样写的。
studentRepo.findByacademicIdAndtermAndacadamicYear(GetId, year,term);
1- You should have pasted the error you were getting when you run this 1-您应该已经粘贴了运行时遇到的错误
2- You just need to make sure the case is correct. 2-您只需要确保大小写正确即可。 Also make sure the order is correct.还要确保顺序正确。 In your case you put the term after the year while in the query you flipped it.在您的情况下,您将术语放在年份之后,而在查询中您将其翻转。 try this:尝试这个:
studentRepo.findByAcademicIdAndTermAndAcadamicYear(int GetId, Term term, String year);
the difference is in the A in Academic
and T in Term
being upper case letter not lower case区别在于Academic
中的 A 和Term
中的 T 是大写字母而不是小写字母
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.