Skip to content

Commit

Permalink
add links to javadoc
Browse files Browse the repository at this point in the history
  • Loading branch information
gavinking committed Sep 4, 2023
1 parent 03c1253 commit b73b4eb
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
10 changes: 5 additions & 5 deletions documentation/src/main/asciidoc/introduction/Configuration.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ The four basic ways to obtain an instance of Hibernate are shown in the followin
| Using the standard JPA-defined XML, and the operation `Persistence.createEntityManagerFactory()`
| Usually chosen when portability between JPA implementations is important.

| Using the `Configuration` class to construct a `SessionFactory`
| Using the link:{doc-javadoc-url}org/hibernate/cfg/Configuration.html[`Configuration`] class to construct a `SessionFactory`
| When portability between JPA implementations is not important, this option is quicker, adds some flexibility and saves a typecast.

| Using the more complex APIs defined in `org.hibernate.boot`
| Using the more complex APIs defined in link:{doc-javadoc-url}org/hibernate/boot/package-summary.html[`org.hibernate.boot`]
| Used primarily by framework integrators, this option is outside the scope of this document.

| By letting the container take care of the bootstrap process and of injecting the `SessionFactory` or `EntityManagerFactory`
Expand Down Expand Up @@ -204,7 +204,7 @@ EntityManagerFactory entityManagerFactory =
[[configuration-api]]
=== Configuration using Hibernate API

Alternatively, the venerable class `org.hibernate.cfg.Configuration` allows an instance of Hibernate to be configured in Java code:
Alternatively, the venerable class link:{doc-javadoc-url}org/hibernate/cfg/Configuration.html[`Configuration`] allows an instance of Hibernate to be configured in Java code.

[source,java]
----
Expand Down Expand Up @@ -263,7 +263,7 @@ hibernate.highlight_sql=true
[[basic-configuration-settings]]
=== Basic configuration settings

The class `org.hibernate.cfg.AvailableSettings` enumerates all the configuration properties understood by Hibernate.
The class link:{doc-javadoc-url}org/hibernate/cfg/AvailableSettings.html[`AvailableSettings`] enumerates all the configuration properties understood by Hibernate.

Of course, we're not going to cover every useful configuration setting in this chapter.
Instead, we'll mention the ones you need to get started, and come back to some other important settings later, especially when we talk about performance tuning.
Expand Down Expand Up @@ -379,7 +379,7 @@ As we mentioned <<testing,earlier>>, it can also be useful to control schema exp
[TIP]
// .Programmatic schema export
====
The `SchemaManager` API allows programmatic control over schema export:
The link:{doc-javadoc-url}org/hibernate/relational/SchemaManager.html[`SchemaManager`] API allows programmatic control over schema export:
[source,java]
sessionFactory.getSchemaManager().exportMappedObjects(true);
Expand Down
8 changes: 4 additions & 4 deletions documentation/src/main/asciidoc/introduction/Interacting.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ Hibernate has a slightly easier way to do it:
boolean authorsFetched = Hibernate.isInitialized(book.getAuthors());
----

But the static methods of the `Hibernate` class let us do a lot more, and it's worth getting a bit familiar them.
But the static methods of the link:{doc-javadoc-url}org/hibernate/Hibernate.html[`Hibernate`] class let us do a lot more, and it's worth getting a bit familiar them.

Of particular interest are the operations which let us work with unfetched collections without fetching their state from the database.
For example, consider this code:
Expand Down Expand Up @@ -463,7 +463,7 @@ From time to time, a _flush_ operation is triggered, and the session synchronize

By default, a flush is triggered:

- when the current transaction commits, for example, when `Transacion.commit()` is called,
- when the current transaction commits, for example, when `Transaction.commit()` is called,
- before execution of a query whose result would be affected by the synchronization of dirty state held in memory, or
- when the program directly calls `flush()`.

Expand Down Expand Up @@ -655,7 +655,7 @@ Using the JPA-standard APIs, this would be a `CriteriaBuilder`, and we get it fr
CriteriaBuilder builder = entityManagerFactory.getCriteriaBuilder();
----

But if we have a `SessionFactory`, we get something much better, a `HibernateCriteriaBuilder`:
But if we have a `SessionFactory`, we get something much better, a link:{doc-javadoc-url}org/hibernate/query/criteria/HibernateCriteriaBuilder.html[`HibernateCriteriaBuilder`]:

[source,java]
----
Expand Down Expand Up @@ -763,7 +763,7 @@ We do.
=== A more comfortable way to write criteria queries

Actually, what makes the JPA criteria API less ergonomic that it should be is the need to call all operations of the `CriteriaBuilder` as instance methods, instead of having them as `static` functions.
The reason it works this way is that each JPA providor has its own implementation of `CriteriaBuilder`.
The reason it works this way is that each JPA provider has its own implementation of `CriteriaBuilder`.

// [%unbreakable]
// [TIP]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ We're all especially grateful to Steve, who has led the project for many years,
We can think of the API of Hibernate in terms of three basic elements:

- an implementation of the JPA-defined APIs, most importantly, of the interfaces `EntityManagerFactory` and `EntityManager`, and of the JPA-defined O/R mapping annotations,
- a _native API_ exposing the full set of available functionality, centered around the interfaces `SessionFactory`, which extends `EntityManagerFactory`, and `Session`, which extends `EntityManager`, and
- a set of _mapping annotations_ which augment the O/R mapping annotations defined by JPA, and which may be used with the JPA-defined interfaces, or with the native API.
- a _native API_ exposing the full set of available functionality, centered around the interfaces link:{doc-javadoc-url}org/hibernate/SessionFactory.html[`SessionFactory`], which extends `EntityManagerFactory`, and link:{doc-javadoc-url}org/hibernate/Session.html[`Session`], which extends `EntityManager`, and
- a set of link:{doc-javadoc-url}org/hibernate/annotations/package-summary.html[_mapping annotations_] which augment the O/R mapping annotations defined by JPA, and which may be used with the JPA-defined interfaces, or with the native API.

Hibernate also offers a range of SPIs for frameworks and libraries which extend or integrate with Hibernate, but we're not interested in any of that stuff here.

Expand Down Expand Up @@ -448,7 +448,7 @@ public class BookResource {
Indeed, we might also _finish_ with something like that—it's quite hard to identify anything concretely wrong with the code above, and for such a simple case it seems really difficult to justify making this code more complicated by introducing additional objects.

One very nice aspect of this code, which we wish to draw your attention to, is that session and transaction management is handled by generic "framework" code, just as we already recommended above.
In this case, we're using the `fromTransaction()` method, which happens to come built in to Hibernate.
In this case, we're using the link:{doc-javadoc-url}org/hibernate/SessionFactory.html#fromTransaction(java.util.function.Function)[`fromTransaction()`] method, which happens to come built in to Hibernate.
But you might prefer to use something else, for example:

- in a container environment like Jakarta EE or Quarkus, _container-managed transactions_ and _container-managed persistence contexts_, or
Expand Down Expand Up @@ -625,7 +625,7 @@ configuration.setProperty(AvailableSettings.JAKARTA_HBM2DDL_DATABASE_ACTION,
Action.SPEC_ACTION_DROP_AND_CREATE);
----

Alternatively, in Hibernate 6, we may use the new `SchemaManager` API to export the schema, just as we did <<main-hibernate,above>>.
Alternatively, in Hibernate 6, we may use the new link:{doc-javadoc-url}org/hibernate/relational/SchemaManager.html[`SchemaManager`] API to export the schema, just as we did <<main-hibernate,above>>.

[source,java]
----
Expand Down
4 changes: 2 additions & 2 deletions documentation/src/main/asciidoc/introduction/Mapping.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ class Book {
Hibernate automatically adjusts the column type used in generated DDL based on the column length specified by the `@Column` annotation.
So we don't usually need to explicitly specify that a column should be of type `TEXT` or `CLOB`—or worry about the parade of `TINYTEXT`, `MEDIUMTEXT`, `TEXT`, `LONGTEXT` types on MySQL—because Hibernate will automatically select one of those types if required to accommodate a string of the `length` we specify.

The constant values defined in the class `org.hibernate.Length` are very helpful here:
The constant values defined in the class link:{doc-javadoc-url}org/hibernate/Length.html[`Length`] are very helpful here:

.Predefined column lengths
[%breakable,cols="10,12,~"]
Expand Down Expand Up @@ -659,7 +659,7 @@ class Book {

The advantage is that a `java.sql.Clob` or `java.sql.Blob` can in principle index up to 2^63^ characters or bytes, much more data than you can fit in a Java `String` or `byte[]` array (or in your computer).

To assign a value to these fields, we'll need to use a `LobHelper`.
To assign a value to these fields, we'll need to use a link:{doc-javadoc-url}org/hibernate/LobHelper.html[`LobHelper`].
We can get one from the `Session`:

[source,java]
Expand Down
10 changes: 5 additions & 5 deletions documentation/src/main/asciidoc/introduction/Tuning.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ The `@Cache` annotation must be specified on the _root class_ of an entity inher
It's 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.
The `@Cache` annotation always specifies a link:{doc-javadoc-url}org/hibernate/annotations/CacheConcurrencyStrategy.html[`CacheConcurrencyStrategy`], a policy governing access to the second-level cache by concurrent transactions.

.Cache concurrency
[%breakable,cols="20,30,~"]
Expand Down Expand Up @@ -838,13 +838,13 @@ And if you find yourself thinking you _do_ need them in a certain situation, you
[[stateless-sessions]]
=== Stateless sessions

An arguably-underappreciated feature of Hibernate is the `StatelessSession` interface, which provides a command-oriented, more bare-metal approach to interacting with the database.
An arguably-underappreciated feature of Hibernate is the link:{doc-javadoc-url}org/hibernate/StatelessSession.html[`StatelessSession`] interface, which provides a command-oriented, more bare-metal approach to interacting with the database.

You may obtain a reactive stateless session from the `SessionFactory`:
You may obtain a stateless session from the `SessionFactory`:

[source, JAVA, indent=0]
----
Stage.StatelessSession ss = getSessionFactory().openStatelessSession();
StatelessSession ss = getSessionFactory().openStatelessSession();
----

A stateless session:
Expand Down Expand Up @@ -960,7 +960,7 @@ We may ask Hibernate to collect statistics about its activity by setting this co
| `hibernate.generate_statistics` | `true` to enable collection of statistics
|===

The statistics are exposed by the `Statistics` object:
The statistics are exposed by the link:{doc-javadoc-url}org/hibernate/stat/Statistics.html[`Statistics`] object:

[source,java]
----
Expand Down

0 comments on commit b73b4eb

Please sign in to comment.