本文整理匯總了Java中org.hibernate.criterion.MatchMode類的典型用法代碼示例。如果您正苦於以下問題:Java MatchMode類的具體用法?Java MatchMode怎麽用?Java MatchMode使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
MatchMode類屬於org.hibernate.criterion包,在下文中一共展示了MatchMode類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getNewsInfoByConditionAndPage
import org.hibernate.criterion.MatchMode; //導入依賴的package包/類
/**
* 根據條件查詢指定新聞
*/
@Override
public List<?> getNewsInfoByConditionAndPage(NewsInfo condition, int page, int pageSize) {
Session session = SessionFactory.getCurrentSession();
Criteria criteria = session.createCriteria(NewsInfo.class);
if (condition != null) {
if (condition.getTopic() != null && condition.getTopic().getId() != null ) {
criteria.add(Restrictions.eq("topic.id", condition.getTopic().getId()));
}
if (condition.getTitle() != null && !"".equals(condition.getTitle())) {
criteria.add(Restrictions.like("title", condition.getTitle(), MatchMode.ANYWHERE));
}
}
criteria.setFirstResult(pageSize * (page - 1));
criteria.setMaxResults(pageSize);
criteria.addOrder(Order.desc("createDate"));
return criteria.list();
}
示例2: findMatchingName
import org.hibernate.criterion.MatchMode; //導入依賴的package包/類
/**
* Search staff list for instructors with matching names
* @param fname First Name
* @param lname Last Name
* @return
*/
public static List findMatchingName(String fname, String lname) {
List list = null;
if ( (fname==null || fname.trim().length()==0)
&& (lname==null || lname.trim().length()==0) )
return list;
Conjunction and = Restrictions.conjunction();
if (fname!=null && fname.trim().length()>0)
and.add(Restrictions.ilike("firstName", fname, MatchMode.START));
if (lname!=null && lname.trim().length()>0)
and.add(Restrictions.ilike("lastName", lname, MatchMode.START));
StaffDAO sdao = new StaffDAO();
list = sdao.getSession()
.createCriteria(Staff.class)
.add(and)
.list();
Collections.sort(list);
return list;
}
示例3: addCriteriaForMaclike
import org.hibernate.criterion.MatchMode; //導入依賴的package包/類
private void addCriteriaForMaclike(OnmsCriteria criteria, String macLike) {
String macLikeStripped = macLike.replaceAll("[:-]", "");
criteria.createAlias("node.snmpInterfaces", "snmpInterface", CriteriaSpecification.LEFT_JOIN);
criteria.createAlias("node.arpInterfaces", "arpInterface", CriteriaSpecification.LEFT_JOIN);
Disjunction physAddrDisjunction = Restrictions.disjunction();
physAddrDisjunction.add(Restrictions.ilike("snmpInterface.physAddr", macLikeStripped, MatchMode.ANYWHERE));
physAddrDisjunction.add(Restrictions.ilike("arpInterface.physAddr", macLikeStripped, MatchMode.ANYWHERE));
criteria.add(physAddrDisjunction);
// This is an alternative to the above code if we need to use the out-of-the-box DetachedCriteria which doesn't let us specify the join type
/*
String propertyName = "nodeId";
String value = "%" + macLikeStripped + "%";
Disjunction physAddrDisjuction = Restrictions.disjunction();
physAddrDisjuction.add(Restrictions.sqlRestriction("{alias}." + propertyName + " IN (SELECT nodeid FROM snmpinterface WHERE snmpphysaddr LIKE ? )", value, new StringType()));
physAddrDisjuction.add(Restrictions.sqlRestriction("{alias}." + propertyName + " IN (SELECT nodeid FROM atinterface WHERE atphysaddr LIKE ? )", value, new StringType()));
criteria.add(physAddrDisjuction);
*/
}
示例4: getKeysImpl
import org.hibernate.criterion.MatchMode; //導入依賴的package包/類
@SuppressWarnings("unchecked")
protected Collection<String> getKeysImpl(Session session, Long piid, String prefix, Type type) throws HibernateException {
if( piid == null )
return Collections.EMPTY_LIST;
Criteria criteria = session.createCriteria(getPersistentClass())
.add(Restrictions.eq("processInstanceId", piid))
.setProjection(Projections.property("key"));
if (prefix != null)
criteria.add(Restrictions.ilike("key", prefix, MatchMode.START));
if(type != null)
criteria.add(Restrictions.eq("type", type.getValue()));
return criteria.list();
}
示例5: getPullRequestReferenceSupport
import org.hibernate.criterion.MatchMode; //導入依賴的package包/類
@Override
protected PullRequestReferenceSupport getPullRequestReferenceSupport() {
return new PullRequestReferenceSupport() {
@Override
public List<PullRequest> findRequests(String query, int count) {
EntityCriteria<PullRequest> criteria = EntityCriteria.of(PullRequest.class);
criteria.add(Restrictions.eq("targetProject", getProject()));
if (StringUtils.isNotBlank(query)) {
query = StringUtils.deleteWhitespace(query);
criteria.add(Restrictions.or(
Restrictions.ilike("noSpaceTitle", query, MatchMode.ANYWHERE),
Restrictions.ilike("numberStr", query, MatchMode.START)));
}
criteria.addOrder(Order.desc("number"));
return GitPlex.getInstance(Dao.class).findRange(criteria, 0, count);
}
};
}
示例6: like
import org.hibernate.criterion.MatchMode; //導入依賴的package包/類
/**
* 模糊匹配
*
* @param fieldName 字段名
* @param value 字段值
* @param matchMode 匹配類型
* @param ignoreNull 是否忽然空值
* @return 條件表達式
* @return
*/
public static SimpleExpression like(String fieldName, String value, MatchMode matchMode, boolean ignoreNull) {
if (StringUtils.isEmpty(value))
return null;
SimpleExpression expression;
switch (matchMode) {
case START:
expression = new SimpleExpression(fieldName, value, Operator.LLIKE);
break;
case END:
expression = new SimpleExpression(fieldName, value, Operator.RLIKE);
break;
case ANYWHERE:
expression = new SimpleExpression(fieldName, value, Operator.LIKE);
break;
default:
expression = new SimpleExpression(fieldName, value, Operator.LIKE);
break;
}
return expression;
}
示例7: buildCriterion
import org.hibernate.criterion.MatchMode; //導入依賴的package包/類
/**
* 按屬性條件參數創建Criterion,輔助函數.
*/
protected Criterion buildCriterion(final String propertyName, final Object propertyValue, final MatchType matchType) {
AssertUtils.hasText(propertyName, "propertyName不能為空");
Criterion criterion = null;
//根據MatchType構造criterion
switch (matchType) {
case EQ:
criterion = Restrictions.eq(propertyName, propertyValue);
break;
case LIKE:
criterion = Restrictions.like(propertyName, (String) propertyValue, MatchMode.ANYWHERE);
break;
case LE:
criterion = Restrictions.le(propertyName, propertyValue);
break;
case LT:
criterion = Restrictions.lt(propertyName, propertyValue);
break;
case GE:
criterion = Restrictions.ge(propertyName, propertyValue);
break;
case GT:
criterion = Restrictions.gt(propertyName, propertyValue);
break;
case NE:
criterion = Restrictions.ne(propertyName, propertyValue);
}
return criterion;
}
示例8: searchByFilter
import org.hibernate.criterion.MatchMode; //導入依賴的package包/類
private Criteria searchByFilter(Short catalog, Integer subCatalog, String keywords, Integer id) {
Criteria cri = getSession().createCriteria(App.class);
if (catalog != null) {
cri.add(Restrictions.eq("catalog", catalog));
}
if (subCatalog != null) {
cri.add(Restrictions.eq("subCatalog", subCatalog));
}
if (id != null && id > 0) {
cri.add(Restrictions.eq("id", id));
}
if (keywords != null && !keywords.isEmpty()) {
cri.add(Restrictions.like("name", keywords, MatchMode.START));
}
return cri;
}
示例9: searchForRolling
import org.hibernate.criterion.MatchMode; //導入依賴的package包/類
@Override
public List<Rollinfo> searchForRolling(Short catalog, Integer subCatalog, int page, int rows, String keywords,
String sort, String order) {
Criteria cri = getSession().createCriteria(Rollinfo.class);
Criteria appCriteria = cri.createCriteria("app", JoinType.LEFT_OUTER_JOIN);
if (catalog != null) {
appCriteria.add(Restrictions.eq("catalog", catalog));
}
if (subCatalog != null) {
appCriteria.add(Restrictions.eq("subCatalog", subCatalog));
}
if (keywords != null && !keywords.isEmpty()) {
appCriteria.add(Restrictions.like("name", keywords, MatchMode.START));
}
if (sort != null && !sort.isEmpty()) {
HibernateHelper.addOrder(appCriteria, sort, order);
}
cri.setMaxResults(rows);
cri.setFirstResult(HibernateHelper.firstResult(page, rows));
List<Rollinfo> list = HibernateHelper.list(cri);
return list;
}
示例10: countForSearchingRolling
import org.hibernate.criterion.MatchMode; //導入依賴的package包/類
@Override
public long countForSearchingRolling(Short catalog, Integer subCatalog, String keywords) {
Criteria cri = getSession().createCriteria(Rollinfo.class);
Criteria appCriteria = cri.createCriteria("app", JoinType.LEFT_OUTER_JOIN);
if (catalog != null) {
appCriteria.add(Restrictions.eq("catalog", catalog));
}
if (subCatalog != null) {
appCriteria.add(Restrictions.eq("subCatalog", subCatalog));
}
if (keywords != null && !keywords.isEmpty()) {
appCriteria.add(Restrictions.like("name", keywords, MatchMode.START));
}
cri.setProjection(Projections.rowCount());
List<Long> list = HibernateHelper.list(cri);
return list.get(0);
}
示例11: searchByFilter
import org.hibernate.criterion.MatchMode; //導入依賴的package包/類
private Criteria searchByFilter(Short type, Short picType, Boolean hidden, String keywords) {
Criteria cri = getSession().createCriteria(MoMixFeatured.class);
if (type != null) {
cri.add(Restrictions.eq("type", type));
}
if (picType != null) {
cri.add(Restrictions.eq("picType", picType));
}
if (hidden != null) {
cri.add(Restrictions.eq("hidden", hidden));
}
if (StringUtils.isNotBlank(keywords)) {
cri.add(Restrictions.like("name", keywords, MatchMode.ANYWHERE));
}
return cri;
}
示例12: searchByFilter
import org.hibernate.criterion.MatchMode; //導入依賴的package包/類
private Criteria searchByFilter(Integer tagId, Integer catalog, Short tagType, String keywords) {
Criteria cri = getSession().createCriteria(ViewTagApps.class);
if (tagType != null) {
cri.add(Restrictions.eq("tagType", tagType));
}
if (tagId != null && tagId > 0) {
cri.add(Restrictions.eq("tagId", tagId));
}
if (catalog != null && catalog > 0) {
cri.add(Restrictions.eq("catalog", catalog));
}
if (keywords != null && !keywords.isEmpty()) {
cri.add(Restrictions.or(Restrictions.like("appName", keywords, MatchMode.ANYWHERE),
Restrictions.like("marketName", keywords, MatchMode.ANYWHERE),
Restrictions.like("tagName", keywords, MatchMode.ANYWHERE)));
}
return cri;
}
示例13: searchByFilter
import org.hibernate.criterion.MatchMode; //導入依賴的package包/類
private Criteria searchByFilter(EnumMarket enumMarket, Short catalog, Integer subCatalog, String keywords,
Integer id, Date startDate, Date endDate) {
Criteria cri = getSession().createCriteria(MarketApp.class);
if (enumMarket != null) {
cri.add(Restrictions.eq("marketName", enumMarket.getName()));
}
if (catalog != null) {
cri.add(Restrictions.eq("catalog", catalog));
}
if (subCatalog != null) {
cri.add(Restrictions.eq("subCatalog", subCatalog));
}
if (id != null && id > 0) {
cri.add(Restrictions.eq("id", id));
}
if (startDate != null && endDate != null) {
cri.add(Restrictions.between("lastUpdateTime", startDate, endDate));
}
if (keywords != null && !keywords.isEmpty()) {
cri.add(Restrictions.like("name", keywords, MatchMode.ANYWHERE));
}
return cri;
}
示例14: searchByFilter
import org.hibernate.criterion.MatchMode; //導入依賴的package包/類
private Criteria searchByFilter(Short type, Boolean hidden, Boolean deleted, String keywords) {
Criteria cri = getSession().createCriteria(MoFeatured.class);
if (type != null) {
cri.add(Restrictions.eq("type", type));
}
if (hidden != null) {
cri.add(Restrictions.eq("hidden", hidden));
}
if (deleted != null) {
cri.add(Restrictions.eq("deleted", deleted));
}
if (StringUtils.isNotBlank(keywords)) {
cri.add(Restrictions.like("name", keywords, MatchMode.ANYWHERE));
}
return cri;
}
示例15: searchByFilter
import org.hibernate.criterion.MatchMode; //導入依賴的package包/類
private Criteria searchByFilter(Integer tagId, Integer catalog, Short tagType, String keywords) {
Criteria cri = getSession().createCriteria(MoViewTagApps.class);
if (tagType != null) {
cri.add(Restrictions.eq("tagType", tagType));
}
if (tagId != null && tagId > 0) {
cri.add(Restrictions.eq("tagId", tagId));
}
if (catalog != null && catalog > 0) {
cri.add(Restrictions.eq("catalog", catalog));
}
if (keywords != null && !keywords.isEmpty()) {
cri.add(Restrictions.or(Restrictions.like("appName", keywords, MatchMode.ANYWHERE),
Restrictions.like("marketName", keywords, MatchMode.ANYWHERE),
Restrictions.like("tagName", keywords, MatchMode.ANYWHERE)));
}
return cri;
}