原生sql
参数为对象
@Query(value = "select * from user_info where username = :#{#user. username} , nativeQuery= true)
User findByUsername(User user);
参数为变量,使用?获取
@Query(value = "select * from user_info where username = ?1 , nativeQuery = true)
User findByUsername(String username);
参数为变量,使用形参名访问
@Query(value = "select * from user_info where username = :username , nativeQuery = true)
User findByUsername(String username);
JPQL
参数为对象
@Query(value = "select u from user_info u where u.username = :#{#user.username} , nativeQuery = true)
User findByUsername(User user);
参数为变量,使用?获取
@Query(value = "select u from user_info u where u.username = ?1, nativeQuery = true)
User findByUsername(String username);
参数为变量,使用形参名访问
@Query(value = "select u from user_info u where u.username = :username , nativeQuery = true)
User findByUsername(String username);