我是学习者,我正在尝试通过userId获取状态列表,但是我仅获得状态表的第一条记录,我的错觉是什么可以帮助我,我尝试了很多,但我不理解我的错觉>
List<StatesDTO>statesList = statesRepository.findByUserid(1);
System.out.println("States list---->"+Conversions.getGson().toJson(statesList));
public interface StatesRepository extends JpaRepository<StatesDTO, Integer>{
List<StatesDTO>findByUserid(int id);
}
@Entity
@Table(name = "states")
public class StatesDTO {
private int userid;
private int stateid;
private String statename;
public int getUserid() {
return userid;
}
public void setUserid(int userid) {
this.userid = userid;
}
public int getStateid() {
return stateid;
}
public void setStateid(int stateid) {
this.stateid = stateid;
}
public String getStatename() {
return statename;
}
public void setStatename(String statename) {
this.statename = statename;
}
}
userid stateid statename
'4', '40', 'up'
'3', '10', 'ap'
'3', '30', 'tn'
'2', '30', 'tn'
'2', '40', 'up'
'1', '10', 'ap'
'1', '20', 'ts'