У меня есть сущность следующим образом
@Entity
public class User {
@Id
private Long id;
@ManyToOne(cascade = CascadeType.ALL)
private Type type;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Type getType() {
return type;
}
public void setType(Type type) {
this.type = type;
}
}
Вызов findOne() или findAll() для этого объекта сгенерировал разные sql
найти все()
Hibernate:
select
user0_.id as id1_1_,
user0_.type_id as type_id2_1_
from
user user0_
Hibernate:
select
type0_.id as id1_0_0_,
type0_.name as name2_0_0_
from
type type0_
where
type0_.id=?
найтиОдин()
Hibernate:
select
user0_.id as id1_1_0_,
user0_.type_id as type_id2_1_0_,
type1_.id as id1_0_1_,
type1_.name as name2_0_1_
from
user user0_
left outer join
type type1_
on user0_.type_id=type1_.id
where
user0_.id=?
почему сгенерированный sql findAll() не использует соединение?
Я создаю пример репозитория по этому вопросу
https://github.com/wensimin/jpa-join-query
Благодарность!