1、查询结果是表的部分字段,而不是全部
- ad是CouponAd 对象
- coupon 是ad的属性,也是一个实体类
select ad.coupon from CouponAd ad where ad.deleted=false Order by createdDate desc
2、like模糊搜索
这里变量key是String类型。
String hql = "from Coupon coupon where coupon.deleted=false and coupon.name like :key"; Map<String, Object> map = new HashMap<>(); map.put("key", ‘%‘ + key + ‘%‘); List<T> list = list(hql, firstResult, maxResults, map);
3、查询总数
public int getTotalCountByStore(int storeid) { Map<String, Object> map = new HashMap<>(); map.put("storeid", storeid); return getTotalCount( "select count(*) from Coupon coupon where coupon.store.id=:storeid", map); }
Done!
时间: 2024-10-24 03:42:18