package com.yanshu.sso.dao; import com.yanshu.sso.pojo.User; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.Repository; import org.springframework.data.repository.query.Param; import java.util.List; public interface UserDao extends JpaRepository<User,Integer> { User findOne(Integer integer); User findByPwd(String pwd); User findByName(String name); User findByNameAndPwd(String name,String pwd); @Query("SELECT U FROM User U ") User selectXuanze(); /** * select u.name ,u.statues from User u where u.name=?1 and u.pwd=?2 * 不能用实体传参,只能用list传参 * @param name * @param pwd * @return */ @Query("select u.name ,u.statues from User u where u.name=?1 and u.pwd=?2 ") List<User> selectstatuc(String name, String pwd); @Query("SELECT U.name,U.statues FROM User U WHERE U.name=?1 AND U.pwd=?2") void selectname(String name,String pwd); }
对springdata jpa 的 @Query和select的理解
最新推荐文章于 2024-08-26 09:40:57 发布