对SpringData Jpa 的 @Query和select的理解

package com.xhz.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import com.xhz.entity.User;

/**
 * 用户Repository接口
 * 
 * @author xhz
 *
 */
public interface UserRepository extends JpaRepository, JpaSpecificationExecutor {

/**
* 通过用户名和密码查询用户信息
* SELECT * FROM XHZ_USER U WHERE U.USER_NAME=?1 AND U.PASSWORD=?2
*  不能用实体传参数,只能用list传参数
* @param userName
* @param password
* @return
*/
@Query(value = "SELECT * FROM XHZ_USER U WHERE U.USER_NAME=?1 AND U.PASSWORD=?2")
public User selectUserInfoByUserNameAndPassword(String userName, String password);

@Query(value = "SELECT * FROM XHZ_USER WHERE USER_NAME=?1 AND PASSWORD=?2")
public User selectUserInfoByUserNameAndPassword(String userName, String password);
}

 

你可能感兴趣的:(Java)