Skip to content

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

@lukasj

Description

@lukasj

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions