예제 #1
0
  protected Criterion getByExampleCriterion(T entity, SearchTemplate searchTemplate) {
    Criterion example = HibernateUtil.constructExample(entity, searchTemplate);
    List<Criterion> extras = getByExampleExtraCriterions(entity, searchTemplate);

    if (extras != null && extras.size() > 0) {
      Junction conjunction = Restrictions.conjunction();
      for (Criterion extra : extras) {
        conjunction.add(extra);
      }
      conjunction.add(example);
      return conjunction;
    } else {
      return example;
    }
  }
예제 #2
0
  @SuppressWarnings("unchecked")
  public List<T> find(T entity, SearchTemplate searchTemplate) {
    Validate.notNull(entity, "The passed entity cannot be null");
    SearchTemplate localSearchTemplate = getLocalSearchTemplate(searchTemplate);

    if (localSearchTemplate.hasNamedQuery()) {
      return (List<T>) getNamedQueryUtil().findByNamedQuery(localSearchTemplate, entity);
    }

    Criteria criteria = getCriteria(entity, localSearchTemplate);
    HibernateUtil.applyPaginationAndOrderOnCriteria(criteria, localSearchTemplate);

    List<T> entities = (List<T>) criteria.list();
    if (log.isDebugEnabled()) {
      log.debug("Returned " + entities.size() + " elements");
    }

    return entities;
  }
예제 #3
0
 protected Criterion getByPatternCriterion(SearchTemplate searchTemplate) {
   return HibernateUtil.constructPattern(persistentClass, searchTemplate);
 }
예제 #4
0
 protected Criterion getByDateCriterion(SearchTemplate searchTemplate) {
   return HibernateUtil.constructDate(searchTemplate);
 }