我正在创建一个带有登录页面的待办事项列表,在该页面中我有两个输入的表作为名称,其中的名称,名称未将数据发送到服务器
这是存储库...
public interface TodosRepository extends CrudRepository<Todos, Long> {
Todos findByName(String name,String things);
List<Todos> findByCompletedAndUserId(boolean complated, Long Id);
}
这是我的实体
@Entity
public class Todos {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String things;
private String name;
private boolean completed;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "user_id")
private User user;
public Todos() {
}
public Todos(String name,String things, boolean completed) {
this.things = things;
this.name = name;
this.completed = completed;
}
public String getThings() {
return things;
}
public void setThings(String things) {
this.things = things;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public boolean isCompleted() {
return completed;
}
public void setCompleted(boolean completed) {
this.completed = completed;
}
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
@Override
public String toString() {
return "Todos [id=" + id + ", name=" + name + ",things=" + things +", completed=" + completed + "]";
}
}
java.util.NoSuchElementException:空
答案 0 :(得分:1)
我认为拼写是错误的,这就是为什么,completed
不是complated
List<Todos> findByCompletedAndUserId(boolean complated, Long Id);
参数名称应与“方法名称”相同。像方法名称有userId
,而参数只有id
答案 1 :(得分:0)
您没有在@Entity
@Table(name = "your-table")