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

What should root.getJoins return after a root.get("x")? #169

Open
lukasj opened this issue Jun 11, 2018 · 3 comments
Open

What should root.getJoins return after a root.get("x")? #169

lukasj opened this issue Jun 11, 2018 · 3 comments

Comments

@lukasj
Copy link
Contributor

lukasj commented Jun 11, 2018

I just found out that the following leads to different results in EclipseLink and Hibernate. And I can't decide from looking at the Spec which is the correct behavior:

CriteriaBuilder builder = em.getCriteriaBuilder();
CriteriaQuery<User> query = builder.createQuery(User.class);
Root<User> root = query.from(User.class);

root.get("manager");

// this returns 1 in EclipseLink and 0 in Hibernate.
root.getJoins()

User is an entity with manager being a self-reference (I don't think the "self" part is relevant here).

@Entity
public class User {
	@Id @GeneratedValue(strategy = GenerationType.AUTO) private Integer id;
	@ManyToOne private User manager;
        // getters and setters omitted for brevity.
}

Please clarify in the specification and in the TCK which one it should be.

@lukasj
Copy link
Contributor Author

lukasj commented Aug 31, 2018

@schauder
Copy link

schauder commented Mar 2, 2021

Related issue in the EclipseLink issue tracker: https://bugs.eclipse.org/bugs/show_bug.cgi?id=413892

@m-reza-rahman
Copy link

This seems like low-hanging fruit that could be looked at in the next release and resolved one way or the other? I would say this is not that high of a priority either way.

Reza Rahman
Jakarta EE Ambassador, Author, Blogger, Speaker

Please note views expressed here are my own as an individual community member and do not reflect the views of my employer.

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

No branches or pull requests

3 participants