Skip to content

Commit

Permalink
"subgraph" and "subtype" are words and do not come with hyphens
Browse files Browse the repository at this point in the history
  • Loading branch information
gavinking committed Jan 2, 2025
1 parent ae4373d commit 392fc72
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion design/working/attributes.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class ForeignCustomer extends Customer {
----

The general idea is that the attributes are ordered alphabetically, super attributes first. Subtypes are sorted
depth-first and the attributes are sorted alphabetically within each sub-type. So the order of the attributes
depth-first and the attributes are sorted alphabetically within each subtype. So the order of the attributes
depends on where we start.

Starting from Customer we have: `[address, name, quota, attr1, attr2, taxId, attr3, attr4, vat]`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ An EntityGraph is the root of a "load plan" and must correspond to an EntityType
[[fetching-strategies-dynamic-fetching-entity-subgraph]]
==== Jakarta Persistence (key) subgraphs

A sub-graph is used to control the fetching of sub-attributes of the AttributeNode it is applied to.
A subgraph is used to control the fetching of sub-attributes of the AttributeNode it is applied to.
It is generally defined via the {jpaJavadocUrlPrefix}NamedSubgraph.html[`@NamedSubgraph`] annotation.

If we have a `Project` parent entity which has an `employees` child associations,
Expand Down Expand Up @@ -264,32 +264,32 @@ include::{extrasdir}/fetching-strategies-dynamic-fetching-entity-subgraph-exampl
----
====

Specifying a sub-graph is only valid for an attribute (or its "key") whose type is a ManagedType. So
Specifying a subgraph is only valid for an attribute (or its "key") whose type is a ManagedType. So
while an EntityGraph must correspond to an EntityType, a Subgraph is legal for any ManagedType. An
attribute's key is defined as either:

* For a singular attribute, the attribute's type must be an IdentifiableType and that IdentifiableType must
have a composite identifier. The "key sub-graph" is applied to the identifier type. The
non-key sub-graph applies to the attribute's value, which must be a ManagedType.
have a composite identifier. The "key subgraph" is applied to the identifier type. The
non-key subgraph applies to the attribute's value, which must be a ManagedType.
* For a plural attribute, the attribute must be a Map and the Map's key value must be a ManagedType.
The "key sub-graph" is applied to the Map's key type. In this case, the non-key sub-graph applies
The "key subgraph" is applied to the Map's key type. In this case, the non-key subgraph applies
to the plural attribute's value/element.


[[fetching-strategies-dynamic-fetching-entity-subgraph-subtype]]
==== Jakarta Persistence SubGraph sub-typing

SubGraphs can also be sub-type specific. Given an attribute whose value is an inheritance hierarchy,
we can refer to attributes of a specific sub-type using the forms of sub-graph definition that accept
the sub-type Class.
Subgraphs can also be subtype specific. Given an attribute whose value is an inheritance hierarchy,
we can refer to attributes of a specific subtype using the forms of subgraph definition that accept
the subtype Class.


[[fetching-strategies-dynamic-fetching-entity-graph-parsing]]
==== Creating and applying Jakarta Persistence graphs from text representations

Hibernate allows the creation of Jakarta Persistence fetch/load graphs by parsing a textual representation
of the graph. Generally speaking, the textual representation of a graph is a comma-separated
list of attribute names, optionally including any sub-graph specifications.
list of attribute names, optionally including any subgraph specifications.
`org.hibernate.graph.GraphParser` is the starting point for such parsing operations.

[NOTE]
Expand All @@ -312,7 +312,7 @@ This example actually functions exactly as <<fetching-strategies-dynamic-fetchin
just using a parsed graph rather than a named graph.


The syntax also supports defining "key sub-graphs". To specify a key sub-graph, `.key` is added
The syntax also supports defining "key subgraphs". To specify a key subgraph, `.key` is added
to the end of the attribute name.

.Parsing an entity key graph
Expand All @@ -331,7 +331,7 @@ include::{example-dir-fetching}/GraphParsingTest.java[tags=fetching-strategies-d
----
====

Parsing can also handle sub-type specific sub-graphs. For example, given an entity hierarchy of
Parsing can also handle subtype specific subgraphs. For example, given an entity hierarchy of
`LegalEntity` <- (`Corporation` | `Person` | `NonProfit`) and an attribute named `responsibleParty` whose
type is the `LegalEntity` base type we might have:

Expand All @@ -342,7 +342,7 @@ responsibleParty(Corporation: ceo)
----
====

We can even duplicate the attribute names to apply different sub-type sub-graphs:
We can even duplicate the attribute names to apply different subtype subgraphs:

====
[source, java, indent=0]
Expand Down

0 comments on commit 392fc72

Please sign in to comment.