Tabnine Logo
TypedQuery.getResultList
Code IndexAdd Tabnine to your IDE (free)

How to use
getResultList
method
in
javax.persistence.TypedQuery

Best Java code snippets using javax.persistence.TypedQuery.getResultList (Showing top 20 results out of 3,276)

Refine searchRefine arrow

  • TypedQuery.setParameter
  • EntityManager.createNamedQuery
  • EntityManager.createQuery
  • CriteriaQuery.from
  • EntityManager.getCriteriaBuilder
  • CriteriaBuilder.createQuery
  • Root.get
origin: spring-projects/spring-data-examples

  @Override
  public List<Account> findByCustomer(Customer customer) {

    TypedQuery<Account> query = em.createQuery("select a from Account a where a.customer = ?1", Account.class);
    query.setParameter(1, customer);

    return query.getResultList();
  }
}
origin: spring-projects/spring-data-examples

  public List<User> myCustomBatchOperation() {

    CriteriaQuery<User> criteriaQuery = em.getCriteriaBuilder().createQuery(User.class);
    criteriaQuery.select(criteriaQuery.from(User.class));
    return em.createQuery(criteriaQuery).getResultList();
  }
}
origin: BroadleafCommerce/BroadleafCommerce

@Override
public List<OrderMultishipOption> readOrderMultishipOptions(final Long orderId) {
  TypedQuery<OrderMultishipOption> query = em.createNamedQuery("BC_READ_MULTISHIP_OPTIONS_BY_ORDER_ID", OrderMultishipOption.class);
  query.setParameter("orderId", orderId);
  return query.getResultList();
}

origin: hibernate/hibernate-orm

@Test
public void test_hql_string_literals_example_1() {
  doInJPA( this::entityManagerFactory, entityManager -> {
    //tag::hql-string-literals-example[]
    List<Person> persons = entityManager.createQuery(
      "select p " +
      "from Person p " +
      "where p.name like 'Joe'", Person.class)
    .getResultList();
    //end::hql-string-literals-example[]
  });
}
origin: javaee-samples/javaee7-samples

  @GET
  @Produces("application/xml")
  public Employee[] get() {
    return em.createNamedQuery("Employee.findAll", Employee.class).getResultList().toArray(new Employee[0]);
  }
}
origin: spring-projects/spring-data-examples

  @Override
  public void removedExpiredAccounts(LocalDate reference) {

    CriteriaBuilder cb = em.getCriteriaBuilder();
    CriteriaQuery<Account> query = cb.createQuery(Account.class);
    Root<Account> account = query.from(Account.class);

    query.where(cb.lessThan(account.get("expiryDate").as(Date.class), reference.toDateTimeAtStartOfDay().toDate()));

    for (Account each : em.createQuery(query).getResultList()) {
      em.remove(each);
    }
  }
}
origin: BroadleafCommerce/BroadleafCommerce

public List<AdminSection> readAdminSectionForClassName(String className) {
  TypedQuery<AdminSection> q = em.createQuery(
    "select s from " + AdminSection.class.getName() + " s where s.ceilingEntity = :className", AdminSection.class);
  q.setParameter("className", className);
  q.setHint(org.hibernate.ejb.QueryHints.HINT_CACHEABLE, true);
  List<AdminSection> result = q.getResultList();
  if (CollectionUtils.isEmpty(result)) {
    return null;
  }
  return q.getResultList();
}
origin: BroadleafCommerce/BroadleafCommerce

  @Override
  public List<AdminUser> readAdminUserByEmail(String emailAddress) {
    TypedQuery<AdminUser> query = em.createNamedQuery("BC_READ_ADMIN_USER_BY_EMAIL", AdminUser.class);
    query.setParameter("email", emailAddress);
    return query.getResultList();
  }
}
origin: hibernate/hibernate-orm

@Test
public void test_hql_select_simplest_jpql_example() {
  doInJPA( this::entityManagerFactory, entityManager -> {
    //tag::hql-select-simplest-jpql-example[]
    List<Person> persons = entityManager.createQuery(
      "select p " +
      "from Person p", Person.class )
    .getResultList();
    //end::hql-select-simplest-jpql-example[]
  });
}
origin: BroadleafCommerce/BroadleafCommerce

@Override
public List<StructuredContent> findAllContentItems() {
  CriteriaBuilder builder = em.getCriteriaBuilder();
  CriteriaQuery<StructuredContent> criteria = builder.createQuery(StructuredContent.class);
  Root<StructuredContentImpl> sc = criteria.from(StructuredContentImpl.class);
  criteria.select(sc);
  try {
    TypedQuery<StructuredContent> query = em.createQuery(criteria);
    query.setHint(QueryHints.HINT_CACHEABLE, true);
    return query.getResultList();
  } catch (NoResultException e) {
    return new ArrayList<StructuredContent>();
  }
}
origin: spring-projects/spring-data-examples

  @Override
  public List<Customer> findByLastname(String lastname, int page, int pageSize) {

    TypedQuery<Customer> query = em.createQuery("select c from Customer c where c.lastname = ?1", Customer.class);

    query.setParameter(1, lastname);
    query.setFirstResult(page * pageSize);
    query.setMaxResults(pageSize);

    return query.getResultList();
  }
}
origin: BroadleafCommerce/BroadleafCommerce

@Override
public List<OrderMultishipOption> readOrderItemOrderMultishipOptions(final Long orderItemId) {
  TypedQuery<OrderMultishipOption> query = em.createNamedQuery("BC_READ_MULTISHIP_OPTIONS_BY_ORDER_ITEM_ID", OrderMultishipOption.class);
  query.setParameter("orderItemId", orderItemId);
  return query.getResultList();
}

origin: hibernate/hibernate-orm

@Test
public void test_hql_abs_function_example() {
  doInJPA( this::entityManagerFactory, entityManager -> {
    //tag::hql-abs-function-example[]
    List<Integer> abs = entityManager.createQuery(
      "select abs( c.duration ) " +
      "from Call c ", Integer.class )
    .getResultList();
    //end::hql-abs-function-example[]
    assertEquals(2, abs.size());
  });
}
origin: BroadleafCommerce/BroadleafCommerce

@Override
public List<URLHandler> findAllURLHandlers() {
  CriteriaBuilder builder = em.getCriteriaBuilder();
  CriteriaQuery<URLHandler> criteria = builder.createQuery(URLHandler.class);
  Root<URLHandlerImpl> handler = criteria.from(URLHandlerImpl.class);
  criteria.select(handler);
  TypedQuery<URLHandler> query = em.createQuery(criteria);
  query.setHint(QueryHints.HINT_CACHEABLE, true);
  try {
    return query.getResultList();
  } catch (NoResultException e) {
    return new ArrayList<URLHandler>();
  }
}
origin: AxonFramework/AxonFramework

@Override
public int[] fetchSegments(String processorName) {
  EntityManager entityManager = entityManagerProvider.getEntityManager();
  final List<Integer> resultList = entityManager.createQuery(
      "SELECT te.segment FROM TokenEntry te "
          + "WHERE te.processorName = :processorName ORDER BY te.segment ASC",
      Integer.class
  ).setParameter("processorName", processorName).getResultList();
  return resultList.stream().mapToInt(i -> i).toArray();
}
origin: BroadleafCommerce/BroadleafCommerce

@Override
public List<CategoryXref> readXrefsByCategoryId(Long categoryId) {
  TypedQuery<CategoryXref> query = em.createNamedQuery("BC_READ_CATEGORY_XREF_BY_CATEGORYID", CategoryXref.class);
  query.setParameter("categoryId", categoryId);
  return query.getResultList();
}
origin: hibernate/hibernate-orm

@Test
public void test_hql_extract_function_example() {
  doInJPA( this::entityManagerFactory, entityManager -> {
    //tag::hql-extract-function-example[]
    List<Integer> years = entityManager.createQuery(
      "select extract( YEAR from c.timestamp ) " +
      "from Call c ", Integer.class )
    .getResultList();
    //end::hql-extract-function-example[]
    assertEquals(2, years.size());
  });
}
origin: BroadleafCommerce/BroadleafCommerce

@Override
public List<PageField> readPageFieldsByPageId(Long pageId) {
  CriteriaBuilder builder = em.getCriteriaBuilder();
  CriteriaQuery<PageField> criteria = builder.createQuery(PageField.class);
  Root<PageFieldImpl> pageField = criteria.from(PageFieldImpl.class);
  criteria.select(pageField);
  Path<Object> path = pageField.get("page").get("id");
  criteria.where(builder.equal(pageField.get("page").get("id"), pageId));
  TypedQuery<PageField> query = em.createQuery(criteria);
  query.setHint(QueryHints.HINT_CACHEABLE, true);
  return query.getResultList();
}
origin: AxonFramework/AxonFramework

@Override
public Optional<Long> lastSequenceNumberFor(String aggregateIdentifier) {
  List<Long> results = entityManager().createQuery(
      "SELECT MAX(e.sequenceNumber) FROM " + domainEventEntryEntityName()
          + " e WHERE e.aggregateIdentifier = :aggregateId", Long.class)
                    .setParameter("aggregateId", aggregateIdentifier)
                    .getResultList();
  if (results.size() == 0) {
    return Optional.empty();
  }
  return Optional.ofNullable(results.get(0));
}
origin: BroadleafCommerce/BroadleafCommerce

@Override
public List<CategoryXref> readXrefsBySubCategoryId(Long subCategoryId) {
  TypedQuery<CategoryXref> query = em.createNamedQuery("BC_READ_CATEGORY_XREF_BY_SUBCATEGORYID", CategoryXref.class);
  query.setParameter("subCategoryId", subCategoryId);
  return query.getResultList();
}
javax.persistenceTypedQuerygetResultList

Javadoc

Execute a SELECT query and return the query results as a typed List.

Popular methods of TypedQuery

  • setParameter
    Bind an instance of java.util.Date to a Parameter object.
  • getSingleResult
    Execute a SELECT query that returns a single result.
  • setMaxResults
    Set the maximum number of results to retrieve.
  • setFirstResult
    Set the position of the first result to retrieve.
  • setHint
    Set a query property or hint. The hints elements may be used to specify query properties and hints.
  • setLockMode
    Set the lock mode type to be used for the query execution.
  • executeUpdate
  • setFlushMode
    Set the flush mode type to be used for the query execution. The flush mode type applies to the query
  • unwrap
  • getHints
  • getParameter
  • getParameters
  • getParameter,
  • getParameters,
  • getFirstResult,
  • getFlushMode,
  • getLockMode,
  • getMaxResults,
  • getParameterValue,
  • isBound,
  • getResultStream

Popular in Java

  • Making http post requests using okhttp
  • getSupportFragmentManager (FragmentActivity)
  • getSharedPreferences (Context)
  • getApplicationContext (Context)
  • Runnable (java.lang)
    Represents a command that can be executed. Often used to run code in a different Thread.
  • SQLException (java.sql)
    An exception that indicates a failed JDBC operation. It provides the following information about pro
  • BitSet (java.util)
    The BitSet class implements abit array [http://en.wikipedia.org/wiki/Bit_array]. Each element is eit
  • NoSuchElementException (java.util)
    Thrown when trying to retrieve an element past the end of an Enumeration or Iterator.
  • LogFactory (org.apache.commons.logging)
    Factory for creating Log instances, with discovery and configuration features similar to that employ
  • Location (org.springframework.beans.factory.parsing)
    Class that models an arbitrary location in a Resource.Typically used to track the location of proble
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now