protected <E> DefaultTupleQueryInfoBean<E, E> createQueryInfoBean(Class<E> entityClass) {
    QueryInfoResultConverter<Tuple, E> resultConverter =
        new DefaultTupleToPojoQueryInfoResultConverter<>(entityClass);

    DefaultTupleQueryInfoBeanContext<E, E> context = new DefaultTupleQueryInfoBeanContext<E, E>();

    context.setEntityContextRegistry(entityContextRegistry);
    context.setEntityManager(entityManager);
    context.setResultConverter(resultConverter);
    context.setRootEntityClass(entityClass);

    DefaultTupleQueryInfoBean<E, E> result = new DefaultTupleQueryInfoBean<>();
    result.setBeanContext(context);

    return result;
  }
 public <E> PaginatedResult<E> queryForPaginatedResult(Class<E> entityClass, QueryInfo queryInfo)
     throws QueryInfoException {
   DefaultTupleQueryInfoBean<E, E> bean = createQueryInfoBean(entityClass);
   return bean.queryForPaginatedResult(queryInfo);
 }
 public <E> E queryForOne(Class<E> entityClass, QueryInfo queryInfo) throws QueryInfoException {
   DefaultTupleQueryInfoBean<E, E> bean = createQueryInfoBean(entityClass);
   return bean.queryForOne(queryInfo);
 }