Technologies:
- Spring-Boot
- Maven
- JPA
I have an entity which contains a one-to-one bidirectional self reference:
@Entity
public class Example {
@Id
@GeneratedValue
Long id;
@Setter
String title;
...
@OneToOne
Example earlierVersion;
@Setter
@OneToOne(mappedBy = "earlierVersion")
Example laterVersion;
}
What I am interested in are the latest versions of Examples. Therefore I am requesting via Spring JPA query methods:
List<Example> findByLaterVersionIsNull();
This is working well with Spring Boot version 1.5.2.REALEASE (maven).
But after a change to Spring Boot version 2.0.0 or higher it seems that the generated SQL which gets executed does not contain the necessary LEFT OUTER JOIN anymore.
E.g.:
Version 1.5.2.RELEASE
select ...
from example example0_
left outer join example example1_ on example0_.id=example1_.earlier_version_id
where (example1_.id is null) ?
After Version 2.0.0.RELEASE
select ...
from combination combinatio0_
where (combinatio0_.id is null)
Of course the later query doesn't make sense at all, since id is the primary key.
So I am pretty sure I did something wrong or just did not have realized that something important has changed. But after researching a lot this will be my first post to this great community to get support.
Thanks in advance!