fix fonts and formatting of tables in pdf
This commit is contained in:
parent
9ae78dd178
commit
f080a724a8
|
@ -6,7 +6,7 @@ Unfortunately, there are several distinct ways to configure and bootstrap Hibern
|
|||
|
||||
The four basic ways to obtain an instance of Hibernate are shown in the following table:
|
||||
|
||||
[cols="1,1"]
|
||||
[cols="50,50"]
|
||||
|===
|
||||
|
||||
| Using the standard JPA-defined XML, and the operation `Persistence.createEntityManagerFactory()`
|
||||
|
@ -57,6 +57,7 @@ You'll also need to add a dependency for the JDBC
|
|||
driver for your database.
|
||||
|
||||
.JDBC driver dependencies
|
||||
[cols="40,~"]
|
||||
|===
|
||||
| Database | Driver dependency
|
||||
|
||||
|
@ -87,6 +88,7 @@ Where `{version}` is the latest version of the JDBC driver for your databse.
|
|||
Optionally, you might also add any of the following additional features:
|
||||
|
||||
.Optional dependencies
|
||||
[cols="40,~"]
|
||||
|===
|
||||
| Optional feature | Dependencies
|
||||
|
||||
|
@ -236,7 +238,7 @@ With rare exception, the default behavior of every one of these settings was car
|
|||
The properties you really do need to get started are these three:
|
||||
|
||||
.JDBC connection settings
|
||||
[cols=",2"]
|
||||
[cols="35,~"]
|
||||
|===
|
||||
| Configuration property name | Purpose
|
||||
|
||||
|
@ -258,7 +260,7 @@ Pooling JDBC connections is an extremely important performance optimization.
|
|||
You can set the size of Hibernate's built-in connection pool using this property:
|
||||
|
||||
.Built-in connection pool size
|
||||
[cols=",2"]
|
||||
[cols="35,~"]
|
||||
|===
|
||||
| Configuration property name | Purpose
|
||||
|
||||
|
@ -275,7 +277,7 @@ This pool is not meant for use in production, and later, when we discuss perform
|
|||
Alternatively, in a container environment, you'll need at least one of these properties:
|
||||
|
||||
.Transaction management settings
|
||||
[cols=",2"]
|
||||
[cols="35,~"]
|
||||
|===
|
||||
| Configuration property name | Purpose
|
||||
|
||||
|
@ -297,18 +299,18 @@ initialization time by specifying one or more of the following configuration
|
|||
properties:
|
||||
|
||||
.Schema management settings
|
||||
[cols=",2"]
|
||||
[cols="52,~"]
|
||||
|===
|
||||
| Configuration property name | Purpose
|
||||
|
||||
| `jakarta.persistence.schema-generation.database.action`
|
||||
a| * If `drop-and-create`, first drop the schema and then export tables, sequences, and constraints.
|
||||
* If `create`, export tables, sequences, and constraints, without attempting to drop them first.
|
||||
* If `create-drop`, drop the schema and recreate it on `SessionFactory` startup.
|
||||
Additionally, drop the schema on `SessionFactory` shutdown.
|
||||
* If `drop`, drop the schema on `SessionFactory` shutdown.
|
||||
* If `validate`, validate the database schema without changing it.
|
||||
* If `update`, only export what's missing in the schema.
|
||||
a| * If `drop-and-create`, first drop the schema and then export tables, sequences, and constraints
|
||||
* If `create`, export tables, sequences, and constraints, without attempting to drop them first
|
||||
* If `create-drop`, drop the schema and recreate it on `SessionFactory` startup
|
||||
Additionally, drop the schema on `SessionFactory` shutdown
|
||||
* If `drop`, drop the schema on `SessionFactory` shutdown
|
||||
* If `validate`, validate the database schema without changing it
|
||||
* If `update`, only export what's missing in the schema
|
||||
|
||||
| `jakarta.persistence.create-database-schemas`
|
||||
| (Optional) If `true`, automatically create schemas and catalogs
|
||||
|
@ -333,7 +335,7 @@ This approach is cleaner than writing Java code to instantiate entity instances
|
|||
[TIP]
|
||||
// .Programmatic schema export
|
||||
====
|
||||
The `SchemaManager` API allow you to control schema export programmatically.
|
||||
Alternatively, the `SchemaManager` API allow you to control schema export programmatically.
|
||||
|
||||
[source,java]
|
||||
sessionFactory.getSchemaManager().exportMappedObjects(true);
|
||||
|
@ -360,7 +362,7 @@ logger.hibernate.level = debug
|
|||
You can make the SQL logged to the console more readable by enabling formatting or highlighting.
|
||||
|
||||
.Settings for SQL logging to the console
|
||||
[cols=",2"]
|
||||
[cols="35,~"]
|
||||
|===
|
||||
| Configuration property name | Purpose
|
||||
|
||||
|
@ -376,7 +378,7 @@ These settings can really help when troubleshooting SQL.
|
|||
The following properties are very useful for minimizing the amount of information you'll need to explicitly specify in `@Table` and `@Column` annotations, which we'll discuss below in <<object-relational-mapping>>:
|
||||
|
||||
.Settings for minimizing explicit mapping information
|
||||
[cols=",2"]
|
||||
[cols="35,~"]
|
||||
|===
|
||||
| Configuration property name | Purpose
|
||||
|
||||
|
@ -402,7 +404,7 @@ Please refer to the Javadoc for these interfaces for more information about the
|
|||
_By default,_ SQL Server's `char` and `varchar` types don't accommodate Unicode data. But a Java string may contain any Unicode character. So, if you're working with SQL Server, you might need to force Hibernate to use the `nchar` and `nvarchar` column types.
|
||||
|
||||
.Setting the use of nationalized character data
|
||||
[cols=",2"]
|
||||
[cols="40,~"]
|
||||
|===
|
||||
| Configuration property name | Purpose
|
||||
|
||||
|
|
|
@ -209,7 +209,7 @@ On the other hand, if, as is more common, you're working with a pre-existing dat
|
|||
JPA defines the following strategies for generating ids, which are enumerated by `GenerationType`:
|
||||
|
||||
.Standard id generation strategies
|
||||
[cols="3,2,6"]
|
||||
[cols="25,15,~"]
|
||||
|===
|
||||
| Strategy | Java type | Implementation
|
||||
|
||||
|
@ -508,7 +508,7 @@ A _basic_ attribute of an entity is a field or property which maps to a single c
|
|||
The JPA specification defines a quite limited set of basic types:
|
||||
|
||||
.JPA-standard basic attribute types
|
||||
[cols="3,2,6"]
|
||||
[cols="30,^14,~"]
|
||||
|====
|
||||
| Classification | Package | Types
|
||||
|
||||
|
@ -541,13 +541,14 @@ As we'll soon see in <<embeddable-objects>>, Hibernate has much better ways to h
|
|||
Hibernate slightly extends this list with the following types:
|
||||
|
||||
.Additional basic attribute types in Hibernate
|
||||
[cols="3,2,6"]
|
||||
[cols="30,^14,56"]
|
||||
|====
|
||||
| Classification | Package | Types
|
||||
|
||||
| Date/time types | `java.time` | `Duration`, `ZoneId`, `ZoneOffset`, `ZonedDateTime`, `Year`
|
||||
| LOB types | `java.sql` | `Blob`, `Clob`
|
||||
| Miscellaneous | `java.util` | `Currency`, `URL`
|
||||
| Additional date/time types | `java.time` | `Duration`, `ZoneId`, `ZoneOffset`, `Year`, and even `ZonedDateTime`
|
||||
| JDBC LOB types | `java.sql` | `Blob`, `Clob`
|
||||
| Java class object | `java.lang` | `Class`
|
||||
| Miscellaneous types | `java.util` | `Currency`, `URL`, `TimeZone`
|
||||
|====
|
||||
|
||||
The `@Basic` annotation explicitly specifies that an attribute is basic, but it's often not needed, since attributes are assumed basic by default.
|
||||
|
@ -917,11 +918,11 @@ There are three annotations for mapping associations: `@ManyToOne`, `@OneToMany`
|
|||
They share some common annotation members:
|
||||
|
||||
.Association-defining annotation members
|
||||
[cols=",4,3"]
|
||||
[cols="14,~,35"]
|
||||
|===
|
||||
| Member | Interpretation | Default value
|
||||
|
||||
| `cascade` | Persistence operations which should <<cascade,cascade>> to the associated entity (a list of ``CascadeType``s) | `{}`
|
||||
| `cascade` | Persistence operations which should <<cascade,cascade>> to the associated entity; a list of ``CascadeType``s | `{}`
|
||||
| `fetch` | Whether the association is eagerly <<association-fetching,fetched>> or may be <<proxies-and-lazy-fetching,proxied>>
|
||||
a|
|
||||
- `LAZY` for `@OneToMany` and `@ManyToMany`
|
||||
|
@ -1204,13 +1205,18 @@ That is, the collection is a _bag_, not a set.
|
|||
|
||||
We've now seen the following kinds of entity attribute:
|
||||
|
||||
[cols="32,^15,^15,~"]
|
||||
|===
|
||||
| Kind of entity attribute | Kind of referenced value | Multiplicity | Examples
|
||||
| Kind of entity attribute | Kind of reference | Multiplicity | Examples
|
||||
|
||||
| Single-valued attribute of basic type | Non-entity | At most one | `@Basic String name`
|
||||
| Single-valued attribute of embeddable type | Non-entity | At most one | `@Embedded Name name`
|
||||
| Single-valued association | Entity | At most one | `@ManyToOne Publisher publisher`, `@OneToOne Person person`
|
||||
| Many-valued association | Entity | Zero or more | `@OneToMany Set<Book> books`, `@ManyToMany Set<Author> authors`
|
||||
| Single-valued association | Entity | At most one |
|
||||
`@ManyToOne Publisher publisher` +
|
||||
`@OneToOne Person person`
|
||||
| Many-valued association | Entity | Zero or more |
|
||||
`@OneToMany Set<Book> books` +
|
||||
`@ManyToMany Set<Author> authors`
|
||||
|===
|
||||
|
||||
Scanning this taxonomy, you might ask: does Hibernate have multivalued attributes of basic or embeddable type?
|
||||
|
@ -1229,11 +1235,16 @@ And the answer again is that _it does_. Indeed, there are two different ways to
|
|||
|
||||
So we may expand our taxonomy with:
|
||||
|
||||
[cols="32,^15,^15,~"]
|
||||
|===
|
||||
| Kind of entity attribute | Kind of referenced value | Multiplicity | Examples
|
||||
| Kind of entity attribute | Kind of reference | Multiplicity | Examples
|
||||
|
||||
| `byte[]` and `char[]` arrays | Non-entity | Zero or more | `byte[] image`, `char[] text`
|
||||
| Collection of basic-typed elements | Non-entity | Zero or more | `@Array String[] names`, `@ElementCollection Set<String> names`
|
||||
| `byte[]` and `char[]` arrays | Non-entity | Zero or more |
|
||||
`byte[] image` +
|
||||
`char[] text`
|
||||
| Collection of basic-typed elements | Non-entity | Zero or more |
|
||||
`@Array String[] names` +
|
||||
`@ElementCollection Set<String> names`
|
||||
| Collection of embeddable elements | Non-entity | Zero or more | `@ElementCollection Set<Name> names`
|
||||
|===
|
||||
|
||||
|
@ -1362,7 +1373,7 @@ There's much more we could say about "element collections", but we won't say it,
|
|||
Let's pause to remember the annotations we've met so far.
|
||||
|
||||
.Declaring entities and embeddable types
|
||||
[cols="2,4,1"]
|
||||
[cols="22,~,^13"]
|
||||
|===
|
||||
| Annotation | Purpose | JPA-standard
|
||||
|
||||
|
@ -1373,7 +1384,7 @@ Let's pause to remember the annotations we've met so far.
|
|||
|===
|
||||
|
||||
.Declaring basic attributes
|
||||
[cols="2,4,2,1"]
|
||||
[cols="22,~,^10,^13"]
|
||||
|===
|
||||
| Annotation | Purpose | Required | JPA-standard
|
||||
|
||||
|
@ -1388,7 +1399,7 @@ Let's pause to remember the annotations we've met so far.
|
|||
|===
|
||||
|
||||
.Converters and compositional basic types
|
||||
[cols="2,4,1"]
|
||||
[cols="22,~,^13"]
|
||||
|===
|
||||
| Annotation | Purpose | JPA-standard
|
||||
|
||||
|
@ -1402,7 +1413,7 @@ Let's pause to remember the annotations we've met so far.
|
|||
|===
|
||||
|
||||
.System-generated identifiers
|
||||
[cols="2,4,1"]
|
||||
[cols="22,~,^13"]
|
||||
|===
|
||||
| Annotation | Purpose | JPA-standard
|
||||
|
||||
|
@ -1414,7 +1425,7 @@ Let's pause to remember the annotations we've met so far.
|
|||
|===
|
||||
|
||||
.Declaring entity associations
|
||||
[cols="2,4,1"]
|
||||
[cols="22,~,^13"]
|
||||
|===
|
||||
| Annotation | Purpose | JPA-standard
|
||||
|
||||
|
|
|
@ -200,7 +200,7 @@ Of course, the main reason we need an `EntityManager` is to do stuff to the data
|
|||
The following important operations let us interact with the persistence context and schedule modifications to the data:
|
||||
|
||||
.Methods for modifying data and managing the persistence context
|
||||
[cols="2,5"]
|
||||
[cols="30,~"]
|
||||
|===
|
||||
| Method name and parameters | Effect
|
||||
|
||||
|
@ -227,7 +227,7 @@ Modifications are automatically detected when the session is <<flush,flushed>>.
|
|||
On the other hand, the following operations all result in immediate access to the database:
|
||||
|
||||
.Methods for reading and locking data
|
||||
[cols="2,5"]
|
||||
[cols="30,~"]
|
||||
|===
|
||||
| Method name and parameters | Effect
|
||||
|
||||
|
@ -358,7 +358,7 @@ s.setHibernateFlushMode(FlushMode.MANUAL);
|
|||
Since flushing is a somewhat expensive operation (the session must dirty-check every entity in the persistence context), setting the flush mode to `COMMIT` can occasionally be a useful optimization.
|
||||
|
||||
.Flush modes
|
||||
[cols=",,3"]
|
||||
[cols="15,15,~"]
|
||||
|===
|
||||
| Hibernate `FlushMode` | JPA `FlushModeType` | Interpretation
|
||||
|
||||
|
@ -397,7 +397,7 @@ Fortunately, HQL is already described in exhaustive (and exhausting) detail in t
|
|||
// The query language is discussed in great detail below in <<query-language>>.
|
||||
|
||||
Here we want to see how to execute a query via the `Session` or `EntityManager` API.
|
||||
The method we call depends on what kind of query it is:
|
||||
The method we call depends on what Kind it is:
|
||||
|
||||
- _selection queries_ return a result list, but do not modify the data, but
|
||||
- _mutation queries_ modify data, and return the number of modified rows.
|
||||
|
@ -405,11 +405,12 @@ The method we call depends on what kind of query it is:
|
|||
Selection queries usually start with the keyword `select` or `from`, whereas mutation queries begin with the keyword `insert`, `update`, or `delete`.
|
||||
|
||||
.Executing HQL
|
||||
[cols="10,36,32,22"]
|
||||
|===
|
||||
| Kind of query | `Session` method | `EntityManager` method | `Query` execution method
|
||||
| Kind | `Session` method | `EntityManager` method | `Query` execution method
|
||||
|
||||
| Selection query | `createSelectionQuery(String,Class)` | `createQuery(String,Class)` | `getResultList()`, `getSingleResult()`, or `getSingleResultOrNull()`
|
||||
| Mutation query | `createMutationQuery(String)` | `createQuery(String)` | `executeUpdate()`
|
||||
| Selection | `createSelectionQuery(String,Class)` | `createQuery(String,Class)` | `getResultList()`, `getSingleResult()`, or `getSingleResultOrNull()`
|
||||
| Mutation | `createMutationQuery(String)` | `createQuery(String)` | `executeUpdate()`
|
||||
|===
|
||||
|
||||
So for the `Session` API we would write:
|
||||
|
@ -432,7 +433,7 @@ List<Book> matchingBooks =
|
|||
.getResultList();
|
||||
----
|
||||
|
||||
The only difference between `createSelectionQuery()` and `createQuery()` is that `createSelectionQuery()` throw an exception if passed a mutation query.
|
||||
The only difference between `createSelectionQuery()` and `createQuery()` is that `createSelectionQuery()` throw an exception if passed a Mutation.
|
||||
|
||||
In the query above, `:titleSearchPattern` is called a _named parameter_.
|
||||
We may also identify parameters by a number.
|
||||
|
@ -584,11 +585,12 @@ If you change the default behavior, and set the property to `INLINE` instead of
|
|||
Execution of a criteria query works almost exactly like execution of HQL.
|
||||
|
||||
.Executing criteria queries
|
||||
[cols="10,36,32,22"]
|
||||
|===
|
||||
| Kind of query | `Session` method | `EntityManager` method | `Query` execution method
|
||||
| Kind | `Session` method | `EntityManager` method | `Query` execution method
|
||||
|
||||
| Selection query | `createSelectionQuery(CriteriaQuery)` | `createQuery(CriteriaQuery)` | `getResultList()`, `getSingleResult()`, or `getSingleResultOrNull()`
|
||||
| Mutation query | `createMutationQuery(CriteriaUpdate)` or `createQuery(CriteriaDelete)` | `createQuery(CriteriaUpdate)` or `createQuery(CriteriaDelte)` | `executeUpdate()`
|
||||
| Selection | `createSelectionQuery(CriteriaQuery)` | `createQuery(CriteriaQuery)` | `getResultList()`, `getSingleResult()`, or `getSingleResultOrNull()`
|
||||
| Mutation | `createMutationQuery(CriteriaUpdate)` or `createQuery(CriteriaDelete)` | `createQuery(CriteriaUpdate)` or `createQuery(CriteriaDelte)` | `executeUpdate()`
|
||||
|===
|
||||
|
||||
For example:
|
||||
|
@ -610,11 +612,12 @@ But ultimately, the true value of ORM is not in avoiding SQL, but in alleviating
|
|||
As we said <<introduction,right up front>>, Hibernate's generated SQL is meant to be used in conjunction with handwritten SQL, and native SQL queries are one of the facilities we provide to make that easy.
|
||||
|
||||
.Executing SQL
|
||||
[cols="10,36,32,22"]
|
||||
|===
|
||||
| Kind of query | `Session` method | `EntityManager` method | `Query` execution method
|
||||
| Kind | `Session` method | `EntityManager` method | `Query` execution method
|
||||
|
||||
| Selection query | `createNativeQuery(String,Class)` | `createNativeQuery(String,Class)` | `getResultList()`, `getSingleResult()`, or `getSingleResultOrNull()`
|
||||
| Mutation query | `createNativeMutationQuery(String)` | `createNativeQuery(String)` | `executeUpdate()`
|
||||
| Selection | `createNativeQuery(String,Class)` | `createNativeQuery(String,Class)` | `getResultList()`, `getSingleResult()`, or `getSingleResultOrNull()`
|
||||
| Mutation | `createNativeMutationQuery(String)` | `createNativeQuery(String)` | `executeUpdate()`
|
||||
| Stored procedure | `createStoredProcedureCall(String)` | `createStoredProcedureQuery(String)` | `execute()`
|
||||
|===
|
||||
|
||||
|
@ -727,11 +730,12 @@ We have to make sure that the class with the `@NamedQuery` annotation will be sc
|
|||
The `@NamedNativeQuery` lets us do the same for native SQL queries.
|
||||
|
||||
.Executing named queries
|
||||
[cols="10,36,32,22"]
|
||||
|===
|
||||
| Kind of query | `Session` method | `EntityManager` method | `Query` execution method
|
||||
| Kind | `Session` method | `EntityManager` method | `Query` execution method
|
||||
|
||||
| Selection query | `createNamedSelectionQuery(String,Class)` | `createNamedQuery(String,Class)` | `getResultList()`, `getSingleResult()`, or `getSingleResultOrNull()`
|
||||
| Mutation query | `createNamedMutationQuery(String)` | `createNamedQuery(String)` | `executeUpdate()`
|
||||
| Selection | `createNamedSelectionQuery(String,Class)` | `createNamedQuery(String,Class)` | `getResultList()`, `getSingleResult()`, or `getSingleResultOrNull()`
|
||||
| Mutation | `createNamedMutationQuery(String)` | `createNamedQuery(String)` | `executeUpdate()`
|
||||
|===
|
||||
|
||||
We execute our named query as follows:
|
||||
|
|
|
@ -174,7 +174,7 @@ is a bad idea, since it's impossible to create a foreign key constraint that tar
|
|||
The following annotations specify exactly how elements of the domain model map to tables of the relational model:
|
||||
|
||||
.Annotations for mapping tables
|
||||
[cols=",5"]
|
||||
[%autowidth.stretch]
|
||||
|===
|
||||
| Annotation | Purpose
|
||||
|
||||
|
@ -211,7 +211,7 @@ class Book { ... }
|
|||
The `@Table` annotation can do more than just specify a name:
|
||||
|
||||
.`@Table` annotation members
|
||||
[cols=",8"]
|
||||
[%autowidth.stretch]
|
||||
|===
|
||||
| Annotation member | Purpose
|
||||
|
||||
|
@ -237,7 +237,7 @@ Instead:
|
|||
The `@SecondaryTable` annotation is even more interesting:
|
||||
|
||||
.`@SecondaryTable` annotation members
|
||||
[cols=",8"]
|
||||
[%autowidth.stretch]
|
||||
|===
|
||||
| Annotation member | Purpose
|
||||
|
||||
|
@ -299,7 +299,7 @@ class Author {
|
|||
Here, there should be a `UNIQUE` constraint on _both_ columns of the association table.
|
||||
|
||||
.`@JoinTable` annotation members
|
||||
[cols=",8"]
|
||||
[%autowidth.stretch]
|
||||
|===
|
||||
| Annotation member | Purpose
|
||||
|
||||
|
@ -322,7 +322,7 @@ To better understand these annotations, we must first discuss column mappings in
|
|||
These annotations specify how elements of the domain model map to columns of tables in the relational model:
|
||||
|
||||
.Annotations for mapping columns
|
||||
[cols=",5"]
|
||||
[%autowidth.stretch]
|
||||
|===
|
||||
| Annotation | Purpose
|
||||
|
||||
|
@ -341,7 +341,7 @@ We use the `@Column` annotation to map basic attributes.
|
|||
The `@Column` annotation is not only useful for specifying the column name.
|
||||
|
||||
.`@Column` annotation members
|
||||
[cols=",8"]
|
||||
[%autowidth.stretch]
|
||||
|===
|
||||
| Annotation member | Purpose
|
||||
|
||||
|
@ -395,7 +395,7 @@ We don't use `@Column` to map associations.
|
|||
The `@JoinColumn` annotation is used to customize a foreign key column.
|
||||
|
||||
.`@JoinColumn` annotation members
|
||||
[cols=",8"]
|
||||
[%autowidth.stretch]
|
||||
|===
|
||||
| Annotation member | Purpose
|
||||
|
||||
|
@ -508,7 +508,7 @@ The `@PrimaryKeyJoinColumn` is a special-purpose annotation for mapping:
|
|||
- the primary key column of the primary table mapped by a subclass in a `JOINED` inheritance hierarchy—which is also a foreign key referencing the primary table mapped by the root entity.
|
||||
|
||||
.`@PrimaryKeyJoinColumn` annotation members
|
||||
[cols=",8"]
|
||||
[%autowidth.stretch]
|
||||
|===
|
||||
| Annotation member | Purpose
|
||||
|
||||
|
@ -559,7 +559,7 @@ So we don't usually need to explicitly specify that a column should be of type `
|
|||
The constant values defined in the class `org.hibernate.Length` are very helpful here:
|
||||
|
||||
.Predefined column lengths
|
||||
[cols=",,8"]
|
||||
[%autowidth.stretch]
|
||||
|===
|
||||
| Constant | Value | Description
|
||||
|
||||
|
@ -738,7 +738,7 @@ So, as we've seen, there are quite a few annotations that affect the mapping of
|
|||
Here we summarize the ones we've just seen in the second half of this chapter, along with some we already mentioned in earlier chapters.
|
||||
|
||||
.Annotations for mapping SQL column types
|
||||
[cols=",3"]
|
||||
[%autowidth.stretch]
|
||||
|===
|
||||
| Annotation | Interpretation
|
||||
|
||||
|
@ -754,7 +754,7 @@ Here we summarize the ones we've just seen in the second half of this chapter, a
|
|||
In addition, there are some configuration properties which have a _global_ affect on how basic types map to SQL column types:
|
||||
|
||||
.Type mapping settings
|
||||
[cols=",2"]
|
||||
[%autowidth.stretch]
|
||||
|===
|
||||
| Configuration property name | Purpose
|
||||
|
||||
|
@ -781,7 +781,7 @@ Hibernate lets us map an attribute of an entity to a SQL formula involving colum
|
|||
Thus, the attribute is a sort of "derived" value.
|
||||
|
||||
.Annotations for mapping formulas
|
||||
[cols=",5"]
|
||||
[%autowidth.stretch]
|
||||
|===
|
||||
| Annotation | Purpose
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ hibernate.agroal.reapTimeout PT10s
|
|||
As long as you set at least one property with the prefix `hibernate.agroal`, the `AgroalConnectionProvider` will be selected automatically.
|
||||
|
||||
.Settings for configuring Agroal
|
||||
[cols=",4"]
|
||||
[cols="37,~"]
|
||||
|===
|
||||
| Configuration property name | Purpose
|
||||
|
||||
|
@ -82,7 +82,7 @@ Batching only helps in cases where a program executes many inserts, updates, or
|
|||
All you need to do is set a single property:
|
||||
|
||||
.Enabling JDBC batching
|
||||
[cols=",3"]
|
||||
[%autowidth.stretch]
|
||||
|===
|
||||
| Configuration property name | Purpose
|
||||
|
||||
|
@ -236,7 +236,7 @@ It is an error to place it on a subclass entity.
|
|||
The `@Cache` annotation always specifies a `CacheConcurrencyStrategy`, a policy governing access to the second-level cache by concurrent transactions.
|
||||
|
||||
.Cache concurrency
|
||||
[cols=",2,3"]
|
||||
[cols="20,30,~"]
|
||||
|===
|
||||
| Concurrency policy | Interpretation | Explanation
|
||||
|
||||
|
@ -327,6 +327,7 @@ But in case it helps, we often test Hibernate with the following configuration,
|
|||
:ehcache-config: https://www.ehcache.org/documentation/
|
||||
|
||||
.EHCache provider configuration
|
||||
[cols="35,~"]
|
||||
|===
|
||||
| Configuration property name | Property value
|
||||
|
||||
|
@ -345,16 +346,18 @@ Alternatively, to use Infinispan as the cache implementation, the following sett
|
|||
:infinispan-hibernate: https://infinispan.org/docs/stable/titles/hibernate/hibernate.html
|
||||
|
||||
.Infinispan provider configuration
|
||||
[cols=",3"]
|
||||
[cols="35,~"]
|
||||
|===
|
||||
| Configuration property name | Property value
|
||||
|
||||
| `hibernate.cache.region.factory_class` | `infinispan`
|
||||
| `hibernate.cache.infinispan.cfg` a|
|
||||
[cols="1,2"]
|
||||
| `hibernate.cache.infinispan.cfg` a| Path to infinispan configuration file, for example:
|
||||
[cols="~,35"]
|
||||
!===
|
||||
! `org/infinispan/hibernate/cache/commons/builder/infinispan-configs.xml` ! for a distributed cache
|
||||
! `org/infinispan/hibernate/cache/commons/builder/infinispan-configs-local.xml` ! to test with local cache
|
||||
! `org/infinispan/hibernate/cache/commons/builder/infinispan-configs.xml`
|
||||
! for a distributed cache
|
||||
! `org/infinispan/hibernate/cache/commons/builder/infinispan-configs-local.xml`
|
||||
! to test with local cache
|
||||
!===
|
||||
|===
|
||||
|
||||
|
@ -363,10 +366,12 @@ You'll find more information about using Infinispan with Hibernate {infinispan-h
|
|||
|
||||
Finally, there's a way to globally disable the second-level cache:
|
||||
|
||||
.Setting to disable caching
|
||||
[cols="35,~"]
|
||||
|===
|
||||
| Configuration property name | Property value
|
||||
|
||||
| `hibernate.cache.use_second_level_cache` | `true` to enable caching, `false` to disable it
|
||||
| `hibernate.cache.use_second_level_cache` | `true` to enable caching, or `false` to disable it
|
||||
|===
|
||||
|
||||
When `hibernate.cache.region.factory_class` is set, this property defaults to `true`.
|
||||
|
@ -376,7 +381,6 @@ When `hibernate.cache.region.factory_class` is set, this property defaults to `t
|
|||
This setting lets us easily disable the second-level cache completely when troubleshooting or profiling performance.
|
||||
====
|
||||
|
||||
|
||||
You can find much more information about the second-level cache in the {second-level-cache}[User Guide].
|
||||
|
||||
[[query-cache]]
|
||||
|
@ -387,7 +391,8 @@ Hibernate also has a way to cache the result sets of queries, though this is onl
|
|||
|
||||
The query cache must be enabled explicitly:
|
||||
|
||||
.Query cache configuration
|
||||
.Setting to enable the query cache
|
||||
[cols="35,~"]
|
||||
|===
|
||||
| Configuration property name | Property value
|
||||
|
||||
|
@ -456,7 +461,7 @@ em.setCacheStoreMode(CacheStoreMode.BYPASS);
|
|||
The JPA-defined cache modes are:
|
||||
|
||||
.JPA-defined cache modes
|
||||
[cols=",3"]
|
||||
[cols="30,~"]
|
||||
|===
|
||||
| Mode | Interpretation
|
||||
|
||||
|
@ -471,9 +476,9 @@ The JPA-defined cache modes are:
|
|||
A Hibernate `CacheMode` packages a `CacheRetrieveMode` with a `CacheStoreMode`.
|
||||
|
||||
.Hibernate cache modes and JPA equivalents
|
||||
[cols=",5"]
|
||||
[cols="30,~"]
|
||||
|===
|
||||
| `CacheMode` | Equivalent JPA modes
|
||||
| Hibernate `CacheMode` | Equivalent JPA modes
|
||||
|
||||
| `NORMAL` | `CacheRetrieveMode.USE`, `CacheStoreMode.USE`
|
||||
| `IGNORE` | `CacheRetrieveMode.BYPASS`, `CacheStoreMode.BYPASS`
|
||||
|
@ -584,7 +589,7 @@ A stateless session:
|
|||
For a stateless session, you're always working with detached objects. Thus, the programming model is a bit different:
|
||||
|
||||
.Important methods of the `StatelessSession`
|
||||
[cols=",2"]
|
||||
[%autowidth.stretch]
|
||||
|===
|
||||
| Method name and parameters | Effect
|
||||
|
||||
|
@ -653,7 +658,7 @@ lock mode can be used to request a pessimistic lock, or to customize the behavio
|
|||
of optimistic locking:
|
||||
|
||||
.Optimistic and pessimistic lock modes
|
||||
[cols=",4"]
|
||||
[cols="26,~"]
|
||||
|===
|
||||
| `LockMode` type | Meaning
|
||||
|
||||
|
|
|
@ -4,25 +4,38 @@ page:
|
|||
font:
|
||||
catalog:
|
||||
merge: false
|
||||
Roboto:
|
||||
normal: Roboto-Regular.ttf
|
||||
italic: Roboto-Italic.ttf
|
||||
bold: Roboto-Bold.ttf
|
||||
bold_italic: Roboto-BoldItalic.ttf
|
||||
Roboto Light:
|
||||
normal: Roboto-Light.ttf
|
||||
italic: Roboto-LightItalic.ttf
|
||||
Emoji:
|
||||
Source Sans Pro:
|
||||
normal: SourceSansPro-Regular.ttf
|
||||
italic: SourceSansPro-Italic.ttf
|
||||
bold: SourceSansPro-Bold.ttf
|
||||
bold_italic: SourceSansPro-BoldItalic.ttf
|
||||
Source Sans Pro Light:
|
||||
normal: SourceSansPro-Light.ttf
|
||||
italic: SourceSansPro-LightItalic.ttf
|
||||
bold: SourceSansPro-SemiBold.ttf
|
||||
bold_italic: SourceSansPro-SemiBoldItalic.ttf
|
||||
Inconsolata Light:
|
||||
normal: Inconsolata-Light.ttf
|
||||
bold: Inconsolata-Light.ttf
|
||||
italic: Inconsolata-Light.ttf
|
||||
OpenSansEmoji:
|
||||
normal: OpenSansEmoji.ttf
|
||||
bold: OpenSansEmoji.ttf
|
||||
italic: OpenSansEmoji.ttf
|
||||
bold_italic: OpenSansEmoji.ttf
|
||||
NotoEmoji:
|
||||
normal: NotoEmoji.ttf
|
||||
bold: NotoEmoji.ttf
|
||||
italic: NotoEmoji.ttf
|
||||
bold_italic: NotoEmoji.ttf
|
||||
fallbacks:
|
||||
- Emoji
|
||||
- OpenSansEmoji
|
||||
- NotoEmoji
|
||||
- Source Sans Pro
|
||||
base:
|
||||
font:
|
||||
color: #151e3d
|
||||
family: Roboto
|
||||
family: Source Sans Pro
|
||||
size: 9
|
||||
line-height-length: 11.5
|
||||
line-height: $base-line-height-length / $base-font-size
|
||||
|
@ -31,13 +44,19 @@ prose:
|
|||
image:
|
||||
width: 70%
|
||||
align: center
|
||||
codespan:
|
||||
font:
|
||||
size: 8.5
|
||||
family: Inconsolata Light
|
||||
color: #281e5d
|
||||
code:
|
||||
font-size: 8
|
||||
font-color: #281e5d
|
||||
font:
|
||||
size: 8.5
|
||||
color: #281e5d
|
||||
family: Inconsolata Light
|
||||
border-width: 0
|
||||
padding: [4,4,4,20]
|
||||
# background-color: #f7f7f7
|
||||
# font-family: Inconsolata
|
||||
sidebar:
|
||||
border-width: 0
|
||||
title:
|
||||
|
@ -64,6 +83,7 @@ list:
|
|||
indent: $base-font-size * 1.5
|
||||
item-spacing: 2
|
||||
table:
|
||||
font-size: 8.5
|
||||
caption:
|
||||
text-align: right
|
||||
side: top
|
||||
|
@ -79,9 +99,6 @@ table:
|
|||
background-color: #f0f0f0
|
||||
cell:
|
||||
padding: 6
|
||||
codespan:
|
||||
font-size: 8
|
||||
font-color: #281e5d
|
||||
footer:
|
||||
border-width: 0
|
||||
quote:
|
||||
|
|
Loading…
Reference in New Issue