Skip to content

Commit 18e4810

Browse files
gavinkingjrenaat
authored andcommitted
aesthetic improvements to pdf docs
1 parent 152c980 commit 18e4810

File tree

3 files changed

+31
-20
lines changed

3 files changed

+31
-20
lines changed

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

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -652,14 +652,14 @@ Using the JPA-standard APIs, this would be a `CriteriaBuilder`, and we get it fr
652652

653653
[source,java]
654654
----
655-
CriteriaBuilder cb = entityManagerFactory.getCriteriaBuilder();
655+
CriteriaBuilder builder = entityManagerFactory.getCriteriaBuilder();
656656
----
657657

658658
But if we have a `SessionFactory`, we get something much better, a `HibernateCriteriaBuilder`:
659659

660660
[source,java]
661661
----
662-
HibernateCriteriaBuilder cb = sessionFactory.getCriteriaBuilder();
662+
HibernateCriteriaBuilder builder = sessionFactory.getCriteriaBuilder();
663663
----
664664

665665
The `HibernateCriteriaBuilder` extends `CriteriaBuilder` and adds many operations that JPQL doesn't have.
@@ -672,15 +672,15 @@ Either:
672672
673673
[source,java]
674674
----
675-
HibernateCriteriaBuilder cb =
675+
HibernateCriteriaBuilder builder =
676676
entityManagerFactory.unwrap(SessionFactory.class).getCriteriaBuilder();
677677
----
678678
679679
Or simply:
680680
681681
[source,java]
682682
----
683-
HibernateCriteriaBuilder cb =
683+
HibernateCriteriaBuilder builder =
684684
(HibernateCriteriaBuilder) entityManagerFactory.getCriteriaBuilder();
685685
----
686686
====
@@ -689,18 +689,18 @@ We're ready to create a criteria query.
689689

690690
[source,java]
691691
----
692-
CriteriaQuery<Book> query = cb.createQuery(Book.class);
692+
CriteriaQuery<Book> query = builder.createQuery(Book.class);
693693
Root<Book> book = query.from(Book.class);
694-
Predicate where = cb.conjunction();
694+
Predicate where = builder.conjunction();
695695
if (titlePattern != null) {
696-
where = cb.and(where, cb.like(book.get(Book_.title), titlePattern));
696+
where = builder.and(where, builder.like(book.get(Book_.title), titlePattern));
697697
}
698698
if (namePattern != null) {
699699
Join<Book,Author> author = book.join(Book_.author);
700-
where = cb.and(where, cb.like(author.get(Author_.name), namePattern));
700+
where = builder.and(where, builder.like(author.get(Author_.name), namePattern));
701701
}
702702
query.select(book).where(where)
703-
.orderBy(cb.asc(book.get(Book_.title)));
703+
.orderBy(builder.asc(book.get(Book_.title)));
704704
----
705705

706706
Here, as before, the classes `Book_` and `Author_` are generated by Hibernate's <<metamodel-generator,JPA Metamodel Generator>>.
@@ -739,9 +739,9 @@ Update, insert, and delete queries work similarly:
739739

740740
[source,java]
741741
----
742-
CriteriaDelete<Book> delete = cb.createCriteriaDelete(Book.class);
742+
CriteriaDelete<Book> delete = builder.createCriteriaDelete(Book.class);
743743
Root<Book> book = delete.from(Book.class);
744-
delete.where(cb.lt(cb.year(book.get(Book_.publicationDate)), 2000));
744+
delete.where(builder.lt(builder.year(book.get(Book_.publicationDate)), 2000));
745745
session.createMutationQuery(delete).executeUpdate();
746746
----
747747

@@ -750,11 +750,11 @@ session.createMutationQuery(delete).executeUpdate();
750750
It's even possible to transform a HQL query string to a criteria query, and modify the query programmatically before execution:
751751
[source,java]
752752
----
753-
HibernateCriteriaBuilder cb = sessionFactory.getCriteriaBuilder();
754-
var query = cb.createQuery("from Book where year(publicationDate) > 2000", Book.class);
753+
HibernateCriteriaBuilder builder = sessionFactory.getCriteriaBuilder();
754+
var query = builder.createQuery("from Book where year(publicationDate) > 2000", Book.class);
755755
var root = (Root<Book>) query.getRootList().get(0);
756-
query.where(cb.like(root.get(Book_.title), cb.literal("Hibernate%")));
757-
query.orderBy(cb.asc(root.get(Book_.title)), cb.desc(root.get(Book_.isbn)));
756+
query.where(builder.like(root.get(Book_.title), builder.literal("Hibernate%")));
757+
query.orderBy(builder.asc(root.get(Book_.title)), builder.desc(root.get(Book_.isbn)));
758758
List<Book> matchingBooks = session.createSelectionQuery(query).getResultList();
759759
----
760760
====
@@ -992,13 +992,13 @@ Consider the following code:
992992

993993
[source,java]
994994
----
995-
var cb = sessionFactory.getCriteriaBuilder();
996-
var query = cb.createTupleQuery();
995+
var builder = sessionFactory.getCriteriaBuilder();
996+
var query = builder.createTupleQuery();
997997
var book = query.from(Book.class);
998998
var bookTitle = book.get(Book_.title);
999999
var bookIsbn = book.get(Book_.isbn);
10001000
var bookPrice = book.get(Book_.price);
1001-
query.select(cb.tuple(bookTitle, bookIsbn, bookPrice));
1001+
query.select(builder.tuple(bookTitle, bookIsbn, bookPrice));
10021002
var resultList = session.createSelectionQuery(query).getResultList();
10031003
for (var result: resultList) {
10041004
String title = result.get(bookTitle);

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -609,11 +609,11 @@ JPA provides a `@Lob` annotation which specifies that a field should be persiste
609609
****
610610
What the spec actually says is that the field should be persisted
611611
612-
> as a large object to a database-supported large object type.
612+
> ...as a large object to a database-supported large object type.
613613
614614
It's quite unclear what this means, and the spec goes on to say that
615615
616-
> the treatment of the `Lob` annotation is provider-dependent
616+
> ...the treatment of the `Lob` annotation is provider-dependent...
617617
618618
which doesn't help much.
619619
****
@@ -627,6 +627,7 @@ So unless you specifically need to use these JDBC LOB APIs, you _don't_ need the
627627

628628
Instead, as we just saw in <<column-lengths>>, all you need is to specify a large enough column `length` to accommodate the data you plan to write to that column.
629629

630+
[%unbreakable]
630631
[WARNING]
631632
// .PostgreSQL `BYTEA` and `TEXT`
632633
====

documentation/src/main/asciidoc/pdf/theme.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,20 @@ sidebar:
6262
title:
6363
align: center
6464
admonition:
65+
label:
66+
vertical-align: top
67+
padding: [4, 8, 4, 8]
6568
column-rule:
6669
style: solid
6770
width: 3
6871
color: #f0f0f0
72+
icon:
73+
tip:
74+
stroke-color: #FFC300
75+
warning:
76+
stroke-color: #FF5733
77+
caution:
78+
stroke-color: #FF5733
6979
heading:
7080
font:
7181
color: #b22222

0 commit comments

Comments
 (0)