JPQL用法

JPQL用法

查询关键字

关键字例子SQL 说明
AndfindByNameAndAddressWhere s.name = ?1 And s.address = ?2
OrfindByNameOrAddressWhere s.name = ?1 Or s.address = ?2
LikefindByNameLikeWhere s.name like ? 1
NotLikefindByNameNotLikeWhere s.name not like ?1
BetweenfindByAgeBetweenWhere s.age between ?1 and ?2
LessThanfindByAgeLessThanWhere s.age < ?1
LessThanEqualfindByAgeLessThanEqualWhere s.age <= ?1
GreaterThanfindByAgeGreaterThanWhere s.age > ?1
GreaterThanEqualfindByAgeGreaterThanEqualWhere s.age >= ?1
OrderByfindSexOrderByAgeDescWhere s.sex=?1 order by s.age desc
InfindByAgeIn(Collectionages)Where s.age in ?1
IsNullfindByAgeIsNullWhere s.age is null
AfterfindByStartDateAfterWhere s.startDate > ?1
BeforefindByStartDateBeforeWhere s.startDate < ?1

除了这些还可以自定义查询
@Query 自定义查询询 ,定制查询 SQL示例:

public interface UserDAO extends Repository<AccountInfo, Long> {

	@Query("select a from AccountInfo a where a.accountId = ?1")
	public AccountInfo findByAccountId(Long accountId);
	
	@Query("select a from AccountInfo a where a.balance > ?1")
	public Page<AccountInfo> findByBalanceGreaterThan(
		Integer balance,Pageable pageable);
	}
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值