When programatically creating EntityGraph subgraphs we need to add subgraphs for keys and values independently using addKeySubgraph(...) and addSubgraph(...) methods. However, each of these method will replace the attribute node from the previous step with a new one. Thus, if we first "add" a key subgraph, adding the value subgraph later will effectively remove the key subgraph and vice versa - if we add the value subgraph first, then the key, the value one will be removed. In other words, the last one wins and the previous state is lost.
For example, given MockEntity.java:
... the following two methods illustrate the the two cases (only the order of adding subgraphs is different):
There is even a debug-level logged note in the org.hibernate.jpa.graph.internal.AbstractGraphNode addAttributeNode() method that seems related to this case (does not expect it) - specifically "Encountered request to add entity graph node [%s] using a name [%s] under which another node is already registered [%s]":