Пример #1
0
 /**
  * 根据查询条件,返回对象列表
  *
  * @param search 查询对象
  * @return
  */
 @SuppressWarnings("unchecked")
 public <X> List<X> search(final Class<T> entityClass, Search search) {
   if (search == null) throw new NullPointerException("Search is null.");
   if (search.getSearchClass() == null) throw new NullPointerException("Search class is null.");
   if (entityClass != null && !search.getSearchClass().equals(entityClass))
     throw new IllegalArgumentException(
         "Search class does not match expected type: " + entityClass.getName());
   return this.searchProcessor.search(
       this.getEntityManager().getPersistEntityManager(), entityClass, search);
 }
Пример #2
0
 /**
  * 根据查询条件,返回符合条件的单个对象,用户单表查询
  *
  * @param search 查询对象
  * @return
  */
 @SuppressWarnings("unchecked")
 public <X> X searchUnique(Search search) {
   if (search == null) throw new NullPointerException("Search is null.");
   if (search.getSearchClass() == null) throw new NullPointerException("Search class is null.");
   return (X)
       this.searchProcessor.searchUnique(
           this.getEntityManager().getPersistEntityManager(), search);
 }
Пример #3
0
 /**
  * 返回记录总数,用于单表查询
  *
  * @param search 查询对象
  * @return
  */
 public int count(Search search) {
   if (search == null) throw new NullPointerException("Search is null.");
   if (search.getSearchClass() == null) throw new NullPointerException("Search class is null.");
   return this.searchProcessor.count(this.getEntityManager().getPersistEntityManager(), search);
 }