Let's say I have two entities.
@Entity
public class Foo {
@Id (...)
private Long id;
@OneToOne(...)
private Bar bar;
// and other fields
}
@Entity
public class Bar {
@Id(...)
private Long id;
// and other fields
}
When I create method FooRepository#findByBarId(Long barId) then the SQL created by Spring Data Jpa is like as belows
select ...
from foo
left outer join bar where foo.id = bar.id
where bar.id = ?
I expected this to be described as below.
select ...
from foo
where foo.bar_id = ?
I know that this can be solved by fixing method into FooRepository#findByBar(Bar bar). But I wanna know the reason for this.