MVC应用程序语法错误

MVC应用程序语法错误

本文介绍了Spring MVC应用程序语法错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个问题:

Spring MVC应用程序

我用一些新代码解决了问题,制作了 StudentDeleteRepository.java StudentDeleteRepositoryImpl.java 并根据用户的建议添加了标签:

I solved with some new code, making StudentDeleteRepository.java and StudentDeleteRepositoryImpl.java and adding the tags as a user suggested:

@Autowired
private StudentDeleteRepository studentDeleteRepository;


@Transactional
public Student delete(Student student) {
    return studentDeleteRepository.save(student);
}

StudentDeleteRepository.java 给出错误:

这是 StudentDeleteRepositoryImpl.java 类:

package com.github.elizabetht.repository;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import com.github.elizabetht.model.Student;

@Repository("studentDeleteRepository")
public interface StudentDeleteRepository extends JpaRepository<Student, Long> {

    @Query("delete s from Student s where s.userName = :userName and s.password = :password")
    Student deleteByLogin(@Param("userName") String userName, @Param("password") String password);

}

推荐答案

delete from Student s where s.userName = ?1 and s.password = ?2

这篇关于Spring MVC应用程序语法错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 19:19