Skip to content

Commit

Permalink
Graphpocalypse: update the docs and migration guide to reflect that k…
Browse files Browse the repository at this point in the history
…ey subgraphs are only for Maps
  • Loading branch information
gavinking committed Jan 3, 2025
1 parent 35466f5 commit 1158838
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -264,16 +264,11 @@ include::{extrasdir}/fetching-strategies-dynamic-fetching-entity-subgraph-exampl
----
====

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:
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.

* For a singular attribute, the attribute's type must be an IdentifiableType and that IdentifiableType must
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 subgraph" is applied to the Map's key type. In this case, the non-key subgraph applies
to the plural attribute's value/element.
If the attribute is a Map and the Map's key is a ManagedType, the "key subgraph" is applied to the Map's key type.
In this case, the non-key subgraph applies to the Map value/element.


[[fetching-strategies-dynamic-fetching-entity-subgraph-subtype]]
Expand Down Expand Up @@ -315,14 +310,6 @@ just using a parsed graph rather than a named graph.
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
====
[source, java, indent=0]
----
include::{example-dir-fetching}/GraphParsingTest.java[tags=fetching-strategies-dynamic-fetching-entity-graph-parsing-key-example-1]
----
====

.Parsing a map key graph
====
[source, java, indent=0]
Expand Down
2 changes: 2 additions & 0 deletions migration-guide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,8 @@ This package has been significantly re-engineered, and the impact of this effort
- some breaking changes to type signatures, and
- a number of deprecations of legacy operations which are now covered by JPA.

Also, a key subgraph now always refers to a `Map` key, and never to an entity id.

We encourage migration to the use of the new JPA-standard operations.

== Deprecations
Expand Down

0 comments on commit 1158838

Please sign in to comment.