code: protected <T, K extends Serializable>
      Query<T> _buildQuery(
                      final DAO<T, K>  dao,
                      final Class<T> type,
                      final QueryParams params
                      )
      {
          Query<T>  query = null;
          try {
              query = dao.createQuery();
              QueryBuilder  builder = _getQueryBuilderFactory().newBuilder( type );
              query = builder.build( query, params );
          } catch (RepositoryConfigurationException ex) {
              throw ex;
          } catch (QueryException ex) {
              throw ex;
          } catch (Exception ex) {
              throw new QueryException( ex );
          }
  
          return query;
      }
docs: *********************************************************************