jakartaee / jakartaee/persistence

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

Open
#169 3 comments 1 reaction 0 assignees View on GitHub
Dominant language
Java
Stars
268
Forks
78
Avg merge
1d 6h
Merged PRs (30d)
13

Description

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:

```java
CriteriaBuilder builder = em.getCriteriaBuilder();
CriteriaQuery query = builder.createQuery(User.class);
Root 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).

```java
@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.

Contributor guide

Open the contributing guide

Research direction

Start with the Criteria API example in the issue and compare the EclipseLink and Hibernate results for root.get("manager") followed by root.getJoins(). Review the applicable Persistence specification and TCK coverage; done means the expected behavior is decided and clarified in both the specification and the TCK.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
documentation, testing
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.