예제 #1
0
 /**
  * 通过orm实体属性名称查询全部
  *
  * @param propertyName orm实体属性名称
  * @param value 值
  * @param restrictionName 约束名称,参考{@link
  *     com.eryansky.common.orm.core.hibernate.CriterionBuilder}的实现类
  * @return List
  */
 public List<T> findByProperty(
     String propertyName, Object value, String restrictionName, Order... orders) {
   Criterion criterion =
       HibernateRestrictionBuilder.getRestriction(propertyName, value, restrictionName);
   Criteria criteria = createCriteria(criterion);
   setOrderToCriteria(criteria, orders);
   return createCriteria(criterion).list();
 }
예제 #2
0
 /**
  * 通过orm实体的属性名称查询单个orm实体
  *
  * @param propertyName 属性名称
  * @param value 值
  * @param restrictionName 约束名称 参考{@link
  *     com.eryansky.common.orm.core.hibernate.CriterionBuilder}的所有实现类
  * @return Object
  */
 public T findUniqueByProperty(String propertyName, Object value, String restrictionName) {
   Criterion criterion =
       HibernateRestrictionBuilder.getRestriction(propertyName, value, restrictionName);
   Criteria criteria = createCriteria(criterion);
   return (T) criteria.uniqueResult();
 }
예제 #3
0
 /**
  * 通过{@link PropertyFilter} 创建 Criterion
  *
  * @param filter 属性过滤器
  * @return {@link org.hibernate.criterion.Criterion}
  */
 protected Criterion createCriterion(PropertyFilter filter) {
   if (filter == null) {
     return null;
   }
   return HibernateRestrictionBuilder.getRestriction(filter);
 }