当前位置: 首页>>代码示例>>Java>>正文


Java Example.enableLike方法代码示例

本文整理汇总了Java中org.hibernate.criterion.Example.enableLike方法的典型用法代码示例。如果您正苦于以下问题:Java Example.enableLike方法的具体用法?Java Example.enableLike怎么用?Java Example.enableLike使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.hibernate.criterion.Example的用法示例。


在下文中一共展示了Example.enableLike方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: searchByExample

import org.hibernate.criterion.Example; //导入方法依赖的package包/类
@Override
public Page<Taxon> searchByExample(Taxon example, boolean ignoreCase,
		boolean useLike) {
	Example criterion = Example.create(example);
	if(ignoreCase) {
		criterion.ignoreCase();
	}
	if(useLike) {
		criterion.enableLike();
	}
	Criteria criteria = getSession().createCriteria(Taxon.class);
	criteria.add(criterion);
	List<Taxon> results = (List<Taxon>) criteria.list();
	Page<Taxon> page = new DefaultPageImpl<Taxon>(results.size(), null, null, results, null);
	return page;
}
 
开发者ID:RBGKew,项目名称:eMonocot,代码行数:17,代码来源:TaxonDaoImpl.java

示例2: getPeloExemplo

import org.hibernate.criterion.Example; //导入方法依赖的package包/类
/**
 * Metodo para listar objetos semelhantes ao Object example
 * 
 * @param exemplo
 *            : objeto Example
 * @param isEnableLike
 *            : True se � para ativar o "Like" na consulta, false para
 *            desativar
 * @param isIgnoreCase
 *            : True se � para ignorar mai�sculas e min�sculas na consulta,
 *            false para case sensitive
 * */
@Transactional(readOnly = true, propagation = Propagation.REQUIRED)
public List getPeloExemplo(Object example, boolean isEnableLike,
		boolean isIgnoreCase) {

	Criteria criteria = this.sessionFactory.getCurrentSession()
			.createCriteria(example.getClass());
	Example sample = Example.create(example);
	if (isEnableLike)
		sample.enableLike(MatchMode.ANYWHERE);

	if (isIgnoreCase)
		sample.ignoreCase();

	sample.excludeZeroes();
	criteria.add(sample);
	return criteria.list();

}
 
开发者ID:LM25TTD,项目名称:autotrack,代码行数:31,代码来源:GenericDao.java

示例3: findByExample

import org.hibernate.criterion.Example; //导入方法依赖的package包/类
public List<?> findByExample(Object entity) {
	Example example = Example.create( entity );
	example.enableLike(MatchMode.ANYWHERE);
	Criteria criteria = getCurrentSession().createCriteria( entity.getClass() );
	criteria.add( example );
	return criteria.add(example).list();
}
 
开发者ID:hserv,项目名称:coordinated-entry,代码行数:8,代码来源:QueryExecutorImpl.java

示例4: searchByExample

import org.hibernate.criterion.Example; //导入方法依赖的package包/类
public Page<Taxon> searchByExample(Taxon example, boolean ignoreCase, boolean useLike) {
	Example criterion = Example.create(example);
	if(ignoreCase) {
		criterion.ignoreCase();
	}
	if(useLike) {
		criterion.enableLike();
	}
	Criteria criteria = getSession().createCriteria(Taxon.class);
	criteria.add(criterion);
	List<Taxon> results = (List<Taxon>) criteria.list();
	Page<Taxon> page = new DefaultPageImpl<Taxon>(results, 0, results.size());
	return page;
}
 
开发者ID:RBGKew,项目名称:powop,代码行数:15,代码来源:TaxonDaoImpl.java

示例5: prepareCriteria

import org.hibernate.criterion.Example; //导入方法依赖的package包/类
private Criteria prepareCriteria(T sample, String[] excludeProps, RelatedCriteria[] relations){
	Criteria result = null;
	
	if(sample == null){
		result = this.getCurrentSession().createCriteria(persistentClass);
	}else{		
		Example example = Example.create(sample);
		example.enableLike(MatchMode.ANYWHERE);
		example.ignoreCase();
		
		if(excludeProps != null)
			for(String prop : excludeProps)
				example.excludeProperty(prop);
		
		result = this.getCurrentSession().createCriteria(persistentClass);
		result.add(example);
		
		//Si existen objetos relacionados
		if(relations != null){
			for(RelatedCriteria relation : relations){
				if( (relation != null) && (relation.isValid()) ){
					
					//Se crea el ejemplo del objeto relacionado
					Example objectEx = Example.create(relation.getObject());
					objectEx.enableLike(MatchMode.ANYWHERE);
					objectEx.ignoreCase();
				
					//Se añade el join a la búsqueda
					result.createCriteria(relation.getName())
						.add(objectEx);
				}
			}
		}
	}
	
	return result;
}
 
开发者ID:malaguna,项目名称:cmdit,代码行数:38,代码来源:BasicHibernateDAOImpl.java

示例6: generateWhere

import org.hibernate.criterion.Example; //导入方法依赖的package包/类
protected Criteria generateWhere(final Where<T> where,
		@Nonnull final Map<String, String> alias, Criteria criteria) {

	if (where != null) {
		EntityExample<T> example = where.getExample();
		if (example != null && example.getEntity() != null) {
			Example ejemplo = Example.create(example.getEntity());
			ejemplo.enableLike(example.getMatchMode().getMatchMode());
			ejemplo.setEscapeCharacter('\\');
			if (example.isIgnoreCase()) {
				ejemplo.ignoreCase();
			}
			if (example.isExcludeZeroes()) {
				ejemplo.excludeZeroes();
			}
			criteria.add(ejemplo);
			if (example.getExcluded() != null) {
				for (String excluded : example.getExcluded()) {
					ejemplo.excludeProperty(excluded);
				}
			}
			this.configureExample(criteria, example.getEntity());
		}
		for (String s : where.getFetchs()) {
			criteria.setFetchMode(s, FetchMode.JOIN);
		}
		helper.applyClauses(criteria, where, alias);
	}

	return criteria;
}
 
开发者ID:fpuna-cia,项目名称:karaku,代码行数:32,代码来源:BaseDAOImpl.java

示例7: listByExample

import org.hibernate.criterion.Example; //导入方法依赖的package包/类
@Override
public List listByExample(Object example) {
	HibernateUtility.getSession().clear();
	Criteria criteria = HibernateUtility.getSession().createCriteria( example.getClass() );
	Example sample = Example.create( example );		
	sample.enableLike(MatchMode.ANYWHERE);
	sample.ignoreCase();
	criteria.add( sample );
	return criteria.list();
}
 
开发者ID:herculeshssj,项目名称:imobiliariaweb,代码行数:11,代码来源:HibernateGenericDao.java


注:本文中的org.hibernate.criterion.Example.enableLike方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。