| The scenario is pretty simple
@Entity(name = "EntityA")
public static class EntityA {
@Id
private Long id;
@OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
@JoinColumn(name = "b_id")
private EntityB b;
}
@Entity(name = "EntityB")
public static class EntityB {
@Id
private Long id;
@OneToOne(mappedBy = "b", fetch = FetchType.EAGER)
private EntityA a;
}
When doing a query like select a from EntityB b left join b.a a everything is ok and the EntityA object is returned as expected, but when also selecting another attribute like select b.id, a from EntityB b left join b.a a the query suddenly produces null instead of the EntityA object. |