Skip to content

Commit 7002ee8

Browse files
committed
shorter method name in doc example
Signed-off-by: Gavin King <[email protected]>
1 parent 743691e commit 7002ee8

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

documentation/src/main/asciidoc/introduction/Introduction.adoc

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -498,8 +498,8 @@ Let's hit the code with our favorite thing, the Extract Method refactoring. We o
498498

499499
[source,java]
500500
----
501-
static List<Book> findBooksByTitleWithPagination(Session session,
502-
String titlePattern, Page page) {
501+
static List<Book> findBooksTitled(Session session,
502+
String titlePattern, Page page) {
503503
return session.createSelectionQuery("from Book where title like ?1 order by title", Book.class)
504504
.setParameter(1, titlePattern)
505505
.setPage(page)
@@ -522,9 +522,9 @@ We need a place to put the annotation, so let's move our query method to a new c
522522
query = "from Book where title like :title order by title")
523523
class Queries {
524524
525-
static List<Book> findBooksByTitleWithPagination(Session session,
526-
String titlePattern, Page page) {
527-
return session.createNamedQuery(Queries_._findBooksByTitle_) //type safe reference to the named query
525+
static List<Book> findBooksTitled(Session session,
526+
String titlePattern, Page page) {
527+
return session.createQuery(Queries_._findBooksByTitle_) //type safe reference to the named query
528528
.setParameter("title", titlePattern)
529529
.setPage(page)
530530
.getResultList();
@@ -549,7 +549,7 @@ Whatever the case, the code which orchestrates a unit of work usually just calls
549549
@Path("books/{titlePattern}")
550550
public List<Book> findBooks(String titlePattern) {
551551
var books = sessionFactory.fromTransaction(session ->
552-
Queries.findBooksByTitleWithPagination(session, titlePattern,
552+
Queries.findBooksTitled(session, titlePattern,
553553
Page.page(RESULTS_PER_PAGE, page)));
554554
return books.isEmpty() ? Response.status(404).build() : books;
555555
}
@@ -569,7 +569,7 @@ Suppose we simplify `Queries` to just the following:
569569
----
570570
interface Queries {
571571
@HQL("where title like :title order by title")
572-
List<Book> findBooksByTitleWithPagination(String title, Page page);
572+
List<Book> findBooksTitled(String title, Page page);
573573
}
574574
----
575575

@@ -582,7 +582,7 @@ We can call it just like we were previously calling our handwritten version:
582582
@Path("books/{titlePattern}")
583583
public List<Book> findBooks(String titlePattern) {
584584
var books = sessionFactory.fromTransaction(session ->
585-
Queries_.findBooksByTitleWithPagination(session, titlePattern,
585+
Queries_.findBooksTitled(session, titlePattern,
586586
Page.page(RESULTS_PER_PAGE, page)));
587587
return books.isEmpty() ? Response.status(404).build() : books;
588588
}
@@ -602,7 +602,7 @@ interface Queries {
602602
EntityManager entityManager();
603603
604604
@HQL("where title like :title order by title")
605-
List<Book> findBooksByTitleWithPagination(String title, Page page);
605+
List<Book> findBooksTitled(String title, Page page);
606606
}
607607
----
608608

@@ -616,7 +616,7 @@ The `Queries` interface is now considered a _repository_, and we may use CDI to
616616
@Path("books/{titlePattern}")
617617
@Transactional
618618
public List<Book> findBooks(String titlePattern) {
619-
var books = queries.findBooksByTitleWithPagination(session, titlePattern,
619+
var books = queries.findBooksTitled(session, titlePattern,
620620
Page.page(RESULTS_PER_PAGE, page));
621621
return books.isEmpty() ? Response.status(404).build() : books;
622622
}

documentation/src/main/asciidoc/introduction/Processor.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ This lets us declare which associations of `Book` should be pre-fetched by annot
572572
// ----
573573
// interface Queries {
574574
// @HQL("from Book where title like :title order by title offset :start fetch first :max rows only")
575-
// List<Book> findBooksByTitleWithPagination(String title, int max, int start);
575+
// List<Book> findBooksTitled(String title, int max, int start);
576576
// }
577577
// ----
578578
//
@@ -583,7 +583,7 @@ This lets us declare which associations of `Book` should be pre-fetched by annot
583583
// [source,java]
584584
// ----
585585
// List<Book> books =
586-
// Queries_.findBooksByTitleWithPagination(entityManager, titlePattern,
586+
// Queries_.findBooksTitled(entityManager, titlePattern,
587587
// RESULTS_PER_PAGE, page*RESULTS_PER_PAGE);
588588
// ----
589589

0 commit comments

Comments
 (0)