jpa查詢刪除相關語句
阿新 • • 發佈:2018-11-27
//id查詢
@Query("SELECT s FROM SysStudent s WHERE id= ? and s.state= '1' ")//and s.state= '1'
SysStudent StudentById(String id);
//模糊查詢
@Query("SELECT s FROM SysStudent s WHERE s.name LIKE ? and s.state= '1' ")//and s.state= '1'
List<SysStudent> findStudentName(String name);
//修改 @Modifying @Query("UPDATE SysStudent s SET s.name= ? , s.sex= ? ,s.age = ? ,s.phone= ? WHERE id= ?") int editStudent(String name,String sex,int age,String phone,String id);
//刪除
@Modifying
@Query("UPDATE SysStudent s SET state= '2' WHERE id= ?")
void deleteStudent(String id);
SysStudent:自己建立的相關實體名
id,state:實體的相關屬性
@Modifying:返回值為int或者void時必須適應此註解