Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EntityGraph addAttributeNodes generic type incorrect #112

Closed
lukasj opened this issue Aug 7, 2015 · 7 comments
Closed

EntityGraph addAttributeNodes generic type incorrect #112

lukasj opened this issue Aug 7, 2015 · 7 comments

Comments

@lukasj
Copy link
Contributor

lukasj commented Aug 7, 2015

The method in EntityGraph (and EntitySubgraph)
public void addAttributeNodes(Attribute<T, ?>... attribute);

should be
public void addAttributeNodes(Attribute... attribute);

since we should be able to write code like this

EntityGraph graph = em.createEntityGraph(SubEntity.class);
graph.addAttributeNodes(SubEntity_.baseEntityField);

yet currently it is a compiler error due to this generic type bug.

The same applies to other methods that refer to Attribute<T, ?>

@lukasj
Copy link
Contributor Author

lukasj commented Aug 7, 2015

@glassfishrobot Commented
Reported by neilstockton

@lukasj
Copy link
Contributor Author

lukasj commented Jan 19, 2016

@glassfishrobot Commented
neilstockton said:
Perhaps this bug ought to be fixed in JPA 2.2 since it is trivial to do?

@lukasj
Copy link
Contributor Author

lukasj commented May 5, 2017

@glassfishrobot Commented
This issue was imported from java.net JIRA JPA_SPEC-112

@lukasj
Copy link
Contributor Author

lukasj commented Jan 19, 2018

@sebek64 Commented
Any news on this issue? We have just encountered this issue, and it took a while to figure out that the spec is wrong. For example, the javadoc here http://www.datanucleus.org/javadocs/javax.persistence/2.1/javax/persistence/Subgraph.html seems to have correct types.

@lukasj
Copy link
Contributor Author

lukasj commented Aug 31, 2018

@andrew-simmons
Copy link

I would suggest that you make T an upper bound:
public void addAttributeNodes(Attribute<? super T, ?>... attribute);

My team ran into this issue with a MappedSuperClass that is inherited by two Entities. We would like to consolidate more code that can be shared, but losing the ability to write type safe entity graphs with generated metamodel classes is a show stopper.

@gavinking
Copy link
Contributor

This is now being done as part of #424, so this one can probably be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants