Closed gavinking closed 12 months ago
Additionally, I'm very confused by this method:
/**
* Add a node to the graph that corresponds to a managed
* type with inheritance. This allows for multiple subclass
* subgraphs to be defined for this node of the entity
* graph. Subclass subgraphs will automatically include the
* specified attributes of superclass subgraphs.
*
* @param attribute attribute
* @param type entity subclass
* @return subgraph for the attribute
* @throws IllegalArgumentException if the attribute's target
* type is not a managed type
* @throws IllegalStateException if the EntityGraph has been
* statically defined
*/
public <X> Subgraph<? extends X> addSubgraph(Attribute<T, X> attribute, Class<? extends X> type);
The Javadoc is extremely cryptic, and the signature is weird. Is it supposed to be doing the equivalent of a treat()
? If so, shouldn't the signature be:
public <X, Y extends X> Subgraph<Y> addSubgraph(Attribute<T, X> attribute, Class<?Y> type);
because with the present signature it doesn't seem like you could do anything useful with it, assuming my interpretation is correct.
I'm also confused by this one:
public <X> Subgraph<? extends X> addSubclassSubgraph(Class<? extends X> type);
which actually makes no sense even without knowing the semantics: Java has wildcard capture, so you don't need the wildcards there.
Perhaps it should be:
public <X extends T> Subgraph<X> addSubclassSubgraph(Class<X> type);
Please see https://github.com/jakartaee/persistence/pull/425 for one set of ideas for how to "fix" all this.
this supersedes #411
There are several problems in the
EntityGraph
interface:addAttributeNodes(Attribute<T, ?>... attribute)
produces the infamous "Unchecked generics array creation for varargs parameter" compiler warning.addAttributeNodes(Attribute<T, ?>... attribute)
should beaddAttributeNodes(Attribute<? super T, ?>... attribute)
<X> Subgraph<X> addSubgraph(Attribute<T, X> attribute)
should be<X> Subgraph<X> addSubgraph(Attribute<? super T, X> attribute)
<X> Subgraph<X> addKeySubgraph(Attribute<T, X> attribute)
is simply wrong. I think it should be<X> Subgraph<X> addKeySubgraph(MapAttribute<T, X, ?> attribute)
.We need to put some thought into these.