The goal of the book being to discuss the performance and not how to write a Java EE application, we will not detail the whole service layer here. However, to ensure a common knowledge of what we are dealing with, we will illustrate the code with one service.
We are using JTA 1.2 with JPA 2.2 to establish a link between our database and the Java model. The QuoteService bean, responsible for managing the Quote persistence, can therefore look like the following:
@Transactional@ApplicationScopedpublic class QuoteService { @PersistenceContext private EntityManager entityManager; public Optional<Quote> findByName(final String name) { return entityManager.createQuery("select q from Quote q where q.name = :name", Quote.class)