JPA数据接口

jpa的数据操作接口

public interface UserRepository extends JpaRepository<User,String>{

/**

* 相当于 select *from user where name=?

* @param name

* @return

*/

public List<User> findByName(String name);

/**

* 相当于select *from user where name like ?

* 但是有一点需要注意的是,%需要我们自己来写

* @param name

* @return

*/

public List<User> findByNameLike(String name);

/**

* 相当于select *from user where name not like ?

* 但是有一点需要注意的是,%需要我们自己来写

* @param name

* @return

*/

public List<User> findByNameNotLike(String name);

/**

* 相当于 select *from user where name <> ?

* @param name

* @return

*/

public List<User> findByNameNot(String name);

/**

* 相当于 select *from user where id in (?)

* @param ids

* @return

*/

public List<User> findByIdIn(List<String> ids);

/**

* 相当于 select *from user where id not in ()

* @param ids

* @return

*/

public List<User> findByIdNotIn(List<String> ids);

/**

* 相当于 select *from user where name=? order by height desc

* @param name

* @return

*/

public List<User> findByNameOrderByHeightDesc(String name);

/**

* 相当于 select *from user where name=? order by height asc

* @param name

* @return

*/

public List<User> findByNameOrderByHeightAsc(String name);

/**

* 相当于 select *from user where name is null

* @return

*/

public List<User> findByNameIsNull();

/**

* 相当于 select *from user where name is not null

* @return

*/

public List<User> findByNameIsNotNull();

/**

* 相当于 select *from user where name =? and height=?

* @param name

* @param height

* @return

*/

public List<User> findByNameAndHeight(String name,int height);

/**

* 相当于 select *from user where name =? or height=?

* @param name

* @param height

* @return

*/

public List<User> findByNameOrHeight(String name,int height);

/**

* 相当于 select *from user where height between ? and ?

* 需要注意的是mysql是有包含两个端点值的

* @param start

* @param end

* @return

*/

public List<User> findByHeightBetween(int start,int end);

/**

* 相当于 select *from user where height < ?

* 需要注意的是mysql是没有包含端点值的

* @param less

* @return

*/

public List<User> findByHeightLessThan(int less);

/**

* 相当于 select *from user where height > ?

* 需要注意的是mysql是没有包含端点值的

* @param greater

* @return

*/

public List<User> findByHeightGreaterThan(int greater);

}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值