0
我有一個有趣的問題,休眠,模型如下所示:休眠甚至生成多個SQL查詢,當我使用LEFT JOIN取
@NamedQueries({
@NamedQuery(name = "A.test", query = "SELECT DISTINCT a FROM A a LEFT JOIN FETCH a.pk.b WHERE a.pk.b.pk.c.id = :cId AND a.pk.b.pk.d.id = :dId")
})
@Entity
@Table(name = "AT")
public class A implements Serializable {
@EmbeddedId
private APK pk;
}
@Embeddable
public class APK implements Serializable {
@ManyToOne
@JoinColumns({@JoinColumn(name = "***", referencedColumnName = "***"),
@JoinColumn(name = "***", referencedColumnName = "***")
})
private B b;
}
@Entity
@Table(name = "BT")
public class B implements Serializable {
@EmbeddedId
private BPK pk;
}
@Embeddable
public class APK implements Serializable {
@ManyToOne
@JoinColumn(name = "***", referencedColumnName = "***")
private C c;
@ManyToOne
@JoinColumn(name = "***", referencedColumnName = "***")
private D d;
}
的問題是,在命名查詢,使額外的SQL查詢.. 。 問題是什麼? 謝謝!
謝謝!它正在工作。但我已閱讀@ManyToOne關聯中的fetchtype設置對查詢沒有任何影響。我想我錯過了一些東西,所以我回到手冊。 :S – nerd 2012-04-01 13:24:33