Я не могу воспроизвести. Даны следующие лица:
@Entity
public class Parent3764122 {
@Id @GeneratedValue
private long id;
@ManyToOne(optional = false/*, fetch=FetchType.EAGER*/) // EAGER by default
//@Fetch(FetchMode.JOIN) // unnecessary
@JoinColumn(name="CHILD_1_ID")
private Child3764122 childInstance1;
@ManyToOne(optional = false/*, fetch=FetchType.EAGER*/) // EAGER by default
//@Fetch(FetchMode.JOIN) // unnecessary
@JoinColumn(name="CHILD_2_ID")
private Child3764122 childInstance2;
@Column(name = "USER_ID")
private String userId;
...
}
и
@Entity
public class Child3764122 {
@Id @GeneratedValue
private Long id;
...
}
Следующий HQL-запрос:
from Parent3764122 p join fetch p.childInstance1 join fetch p.childInstance2 where p.id = :id
Создает следующий SQL:
select
parent3764x0_.id as id129_0_,
child37641x1_.id as id130_1_,
child37641x2_.id as id130_2_,
parent3764x0_.CHILD_1_ID as CHILD3_129_0_,
parent3764x0_.CHILD_2_ID as CHILD4_129_0_,
parent3764x0_.USER_ID as USER2_129_0_
from
Parent3764122 parent3764x0_
inner join
Child3764122 child37641x1_
on parent3764x0_.CHILD_1_ID=child37641x1_.id
inner join
Child3764122 child37641x2_
on parent3764x0_.CHILD_2_ID=child37641x2_.id
where
parent3764x0_.id=?
Работает как положено с Hibernate 3.3.0.SP1, Hibernate Annotations 3.4.0.GA.