如何通过传递两个参数来修复方法调用函数

我正在创建一个带有登录页面的待办事项列表,其中有一个两个输入表作为名称,名称中的事物,事物不向服务器发送数据


这是存储库...


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:null


HUH函数
浏览 120回答 2
2回答

30秒到达战场

我认为拼写错误,这就是原因,completed而不是complated&nbsp;List<Todos> findByCompletedAndUserId(boolean complated, Long Id);&nbsp;参数名称应该与方法名称相同。就像方法名称有userId而参数只有id

慕雪6442864

你没有这个注释,请尝试使用下面的这一行@Entity@Table(name&nbsp;=&nbsp;"your-table")
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java