當前位置: 首頁>>代碼示例>>Java>>正文


Java Example.excludeProperty方法代碼示例

本文整理匯總了Java中org.hibernate.criterion.Example.excludeProperty方法的典型用法代碼示例。如果您正苦於以下問題:Java Example.excludeProperty方法的具體用法?Java Example.excludeProperty怎麽用?Java Example.excludeProperty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.hibernate.criterion.Example的用法示例。


在下文中一共展示了Example.excludeProperty方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: findByExample

import org.hibernate.criterion.Example; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
@Override
public List<T> findByExample(T exampleInstance, String... excludeProperty) {
	try {
		Criteria crit = getSession().createCriteria(getPersistentClass());
		Example example = Example.create(exampleInstance);
		for (String exclude : excludeProperty) {
			example.excludeProperty(exclude);
		}
		crit.add(example);
		return crit.list();
	} catch (Exception e) {
		// e.printStackTrace();
		getTransaction().rollback();
		return null;
	}
}
 
開發者ID:schogini,項目名稱:jVoiD,代碼行數:18,代碼來源:GenericHibernateDAO.java

示例2: findByExample

import org.hibernate.criterion.Example; //導入方法依賴的package包/類
/**
 * @param <T>
 * @param exampleInstance
 * @param excludeZeros
 * @param excludeProperty
 * @return
 * @see edu.utah.further.core.api.data.Dao#findByExample(edu.utah.further.core.api.data.PersistentEntity,
 *      boolean, java.lang.String[])
 */
@Override
public <T extends PersistentEntity<?>> List<T> findByExample(final T exampleInstance,
		final boolean excludeZeros, final String... excludeProperty)
{
	final GenericCriteria crit = createCriteria(exampleInstance.getClass());
	final Example example = Example.create(exampleInstance);
	if (excludeZeros)
	{
		example.excludeZeroes();
	}
	for (final String exclude : excludeProperty)
	{
		example.excludeProperty(exclude);
	}
	crit.add(example);
	return getNullSafeList(crit.<T> list());
}
 
開發者ID:openfurther,項目名稱:further-open-core,代碼行數:27,代碼來源:DaoHibernateImpl.java

示例3: findByExample

import org.hibernate.criterion.Example; //導入方法依賴的package包/類
/**
 * @see GenericDao#findByExample(Object, String...)
 */
@SuppressWarnings("unchecked")
public List<T> findByExample(T exampleInstance, String... excludeProperty)
      throws DataAccessException {
   try {
      Criteria crit = getSession().createCriteria(getPersistentClass());
      Example example = Example.create(exampleInstance);
      for (String exclude : excludeProperty) {
         example.excludeProperty(exclude);
      }
      crit.add(example);
      return crit.list();
   } catch (HibernateException e) {
      throw SessionFactoryUtils.convertHibernateAccessException(e);
   }
}
 
開發者ID:kumaramit01,項目名稱:FlowService,代碼行數:19,代碼來源:GenericDaoImpl.java

示例4: findByExample

import org.hibernate.criterion.Example; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public List<T> findByExample(T exampleInstance, String[] excludeProperty) {
	Criteria crit = getSession().createCriteria(getPersistentClass());
	Example example =  Example.create(exampleInstance);
	for (String exclude : excludeProperty) {
	    example.excludeProperty(exclude);
	}
	crit.add(example);
	return crit.list();
}
 
開發者ID:giuseppeurso-eu,項目名稱:struts-mvc,代碼行數:11,代碼來源:GenericHibernateDAO.java

示例5: findByExample

import org.hibernate.criterion.Example; //導入方法依賴的package包/類
@Override
@SuppressWarnings({"unchecked"})
public List<T> findByExample(T exampleInstance, String... excludeProperty) {
    Criteria crit = getSession().createCriteria(getPersistentClass());
    Example example = Example.create(exampleInstance);
    for (String exclude : excludeProperty) {
        example.excludeProperty(exclude);
    }
    crit.add(example);
    return crit.list();
}
 
開發者ID:alfameCom,項目名稱:salasanasiilo,代碼行數:12,代碼來源:GenericHibernateDAO.java

示例6: 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

示例7: findByExample

import org.hibernate.criterion.Example; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public List<T> findByExample(T exampleInstance, String[] excludeProperty) {
    Criteria crit = getSession().createCriteria(getPersistentClass());
    Example example = Example.create(exampleInstance);
    for (String exclude : excludeProperty) {
        example.excludeProperty(exclude);
    }
    crit.add(example);
    return crit.list();
}
 
開發者ID:MSaifAsif,項目名稱:sample-skeleton-projects,代碼行數:11,代碼來源:GenericHibernateDAO.java

示例8: 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

示例9: findByExample

import org.hibernate.criterion.Example; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public List<T> findByExample(T exampleInstance, String[] excludeProperty) {
    Criteria crit = getSession().createCriteria(getPersistentClass());
    Example example = Example.create(exampleInstance).excludeZeroes().enableLike().ignoreCase();
    for (String exclude : excludeProperty) {
        example.excludeProperty(exclude);
    }
    crit.add(example);
    return crit.list();
}
 
開發者ID:faramir,項目名稱:ZawodyWeb,代碼行數:11,代碼來源:AbstractHibernateDAO.java

示例10: findByExample

import org.hibernate.criterion.Example; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public List<T> findByExample(T exampleInstance, String[] excludeProperty) {
	Criteria crit = getSession().createCriteria(getPersistentClass());
	Example example = Example.create(exampleInstance);
	for (String exclude : excludeProperty) {
		example.excludeProperty(exclude);
	}
	crit.add(example);
	List<T> results = crit.list();
	return results;
}
 
開發者ID:ProjetoAmadeus,項目名稱:AmadeusLMS,代碼行數:12,代碼來源:GenericHibernateDAO.java

示例11: findUniqueByExample

import org.hibernate.criterion.Example; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public T findUniqueByExample(T exampleInstance, String[] excludeProperty) {
	Criteria crit = getSession().createCriteria(getPersistentClass());
	Example example = Example.create(exampleInstance);
	for (String exclude : excludeProperty) {
		example.excludeProperty(exclude);
	}
	crit.add(example);
	T result = (T)crit.uniqueResult();
	return result;
}
 
開發者ID:ProjetoAmadeus,項目名稱:AmadeusLMS,代碼行數:12,代碼來源:GenericHibernateDAO.java

示例12: createExample

import org.hibernate.criterion.Example; //導入方法依賴的package包/類
Criterion createExample(Object entity, MatchMode matchMode, boolean excludeNulls, boolean excludeZeroes,
        Collection<String> excludeProperties) {
    final Example example = Example.create(entity).enableLike(matchMode).ignoreCase();
    if (excludeZeroes) {
        example.excludeZeroes();
    } else if (!excludeNulls) {
        example.excludeNone();
    }
    for (final String property : excludeProperties) {
        example.excludeProperty(property);
    }

    // ID property is not handled by Example, so we have to special case it
    final PersistentClass pclass = getClassMapping(entity.getClass());
    Object idVal = null;
    if (pclass != null && pclass.hasIdentifierProperty()) {
        try {
            idVal = PropertyUtils.getProperty(entity, pclass.getIdentifierProperty().getName());
        } catch (final Exception e) {
            LOG.warn("Could not retrieve identifier value in a by example query, ignoring it", e);
        }
    }
    if (idVal == null) {
        return example;
    } else {
        return Restrictions.and(Restrictions.idEq(idVal), example);
    }
}
 
開發者ID:NCIP,項目名稱:caarray,代碼行數:29,代碼來源:AbstractCaArrayDaoImpl.java

示例13: findByExample

import org.hibernate.criterion.Example; //導入方法依賴的package包/類
public List<T> findByExample(T exampleInstance,String... excludeProperty) {
    Criteria crit = getSession().createCriteria(entityType);
    Example example =  Example.create(exampleInstance);
    for (String exclude : excludeProperty) {
        example.excludeProperty(exclude);
    }
    crit.add(example);
    return crit.list();
}
 
開發者ID:OpenHDS,項目名稱:openhds-server,代碼行數:10,代碼來源:BaseDaoImpl.java

示例14: findByExample

import org.hibernate.criterion.Example; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public <T> List<T> findByExample(Class<T> entityType, T exampleInstance, String... excludeProperty) {
    Criteria crit = getSession().createCriteria(entityType);
    Example example = Example.create(exampleInstance);
    for (String exclude : excludeProperty) {
        example.excludeProperty(exclude);
    }
    crit.add(example);
    return crit.list();
}
 
開發者ID:OpenHDS,項目名稱:openhds-server,代碼行數:11,代碼來源:GenericDaoImpl.java

示例15: excludeBooleanFields

import org.hibernate.criterion.Example; //導入方法依賴的package包/類
/**
 * Get a hibernate Example object that excludes zeroes values and excludes
 * all boolean -primitive and wrapper class- attributes of a given object.  
 * @param instance given object for a build a Example object.
 * @return a hibernate Example object.
 */
public static Example excludeBooleanFields (Object instance) {
	Example result = Example.create(instance).excludeZeroes();
	Set<String> fieldNames = getFieldNamesByType(instance, Boolean.class);
	fieldNames.addAll(getFieldNamesByType(instance, Boolean.TYPE));
	for (String fieldName : fieldNames) {
		result.excludeProperty(fieldName);
	}
	return result;
}
 
開發者ID:chelu,項目名稱:jdal,代碼行數:16,代碼來源:HibernateUtils.java


注:本文中的org.hibernate.criterion.Example.excludeProperty方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。