fix a diagram and add alt text
This commit is contained in:
parent
e846fd88d9
commit
edb0a27197
|
@ -934,16 +934,17 @@ An association between entity classes may be either:
|
||||||
- _unidirectional_, navigable from `E` to `F` but not from `F` to `E`, or
|
- _unidirectional_, navigable from `E` to `F` but not from `F` to `E`, or
|
||||||
- _bidirectional_, and navigable in either direction.
|
- _bidirectional_, and navigable in either direction.
|
||||||
|
|
||||||
In this diagram, we can see the sorts of associations which are possible.
|
In this example data model, we can see the sorts of associations which are possible:
|
||||||
|
|
||||||
image::images/associations.png[]
|
image::images/associations.png[Example data model,align="center",pdfwidth=90%]
|
||||||
|
|
||||||
[TIP]
|
[TIP]
|
||||||
// .One-to-one associations and subtyping
|
// .One-to-one associations and subtyping
|
||||||
====
|
====
|
||||||
An astute observer of the diagram above might notice that the relationships we've represented as unidirectional one-to-one associations could reasonably be represented in Java using subtyping.
|
An astute observer of the diagram above might notice that the relationship we've presented as a unidirectional one-to-one association could reasonably be represented in Java using subtyping.
|
||||||
This is quite normal.
|
This is quite normal.
|
||||||
A one-to-one association is the usual way we implement subtyping in a fully-normalized relational model.
|
A one-to-one association is the usual way we implement subtyping in a fully-normalized relational model.
|
||||||
|
It's related to the `JOINED` <<mapping-inheritance,inheritance mapping>> strategy.
|
||||||
====
|
====
|
||||||
|
|
||||||
There are three annotations for mapping associations: `@ManyToOne`, `@OneToMany`, and `@ManyToMany`.
|
There are three annotations for mapping associations: `@ManyToOne`, `@OneToMany`, and `@ManyToMany`.
|
||||||
|
|
|
@ -48,7 +48,7 @@ Thus, an entity instance may be in one of three states with respect to a given p
|
||||||
2. _persistent_ — currently associated with the persistence context, or
|
2. _persistent_ — currently associated with the persistence context, or
|
||||||
3. _detached_ — previously persistent in another session, but not currently associated with _this_ persistence context.
|
3. _detached_ — previously persistent in another session, but not currently associated with _this_ persistence context.
|
||||||
|
|
||||||
image:images/entity-lifecyle.png[width=800,align="center"]
|
image::images/entity-lifecyle.png[Entity lifecycle,width=800,align="center"]
|
||||||
|
|
||||||
At any given moment, an instance may be associated with at most one persistence context.
|
At any given moment, an instance may be associated with at most one persistence context.
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ We can think of the API of Hibernate in terms of three basic elements:
|
||||||
- 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 _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 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.
|
||||||
|
|
||||||
image::images/api-overview.png[width=700,align="center"]
|
image::images/api-overview.png[API overview,width=700,align="center"]
|
||||||
|
|
||||||
As an application developer, you must decide whether to:
|
As an application developer, you must decide whether to:
|
||||||
|
|
||||||
|
|
|
@ -108,7 +108,7 @@ fundamental rule of thumb in ORM is:
|
||||||
of a session/transaction, and fetch it immediately in one or two queries,
|
of a session/transaction, and fetch it immediately in one or two queries,
|
||||||
- and only then start navigating associations between persistent entities.
|
- and only then start navigating associations between persistent entities.
|
||||||
|
|
||||||
image:images/fetching.png[width=700,align="center"]
|
image::images/fetching.png[Fetching process,width=700,align="center"]
|
||||||
|
|
||||||
Without question, the most common cause of poorly-performing data access
|
Without question, the most common cause of poorly-performing data access
|
||||||
code in Java programs is the problem of _N+1 selects_. Here, a list of N
|
code in Java programs is the problem of _N+1 selects_. Here, a list of N
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 94 KiB |
Binary file not shown.
Before Width: | Height: | Size: 212 KiB After Width: | Height: | Size: 110 KiB |
Loading…
Reference in New Issue