QBC查询之字符串模式匹配

 

Criteria 字符串模式匹配
1.通配符方式 "%" " _"


 Criteria criteria = session.createCriteria(Person.class).add(Restrictions.like("name", "q%"));

 

2.MatchMode方式

MatchMode.START Expression.like("name","q", MatchMode.START) 姓名以q开头
MatchMode.END Expression.like("name","q", MatchMode. END) 姓名以q结尾
MatchMode.ANYWHERE Expression.like("name","q", MatchMode. ANYWHERE) 姓名中包含q
MatchMode.EXACT Expression.like("name","q", MatchMode. EXACT) 精确匹配,姓名必须为q

你可能感兴趣的:(字符串)