+-------+ +--------------| +-------+
| BOY | | BOY_GIRL | | GIRL |
+-------+ +--------------| +-------+
| id | | id | | id |
| name | | boy_id | | name |
| birth | | girl_id | | birth |
+-------+ | start_dating | +-------+
+--------------|
START_DATING
加入的類型是TIMESTAMP
或DATE
Hibernate的許多一對多與條件
我有兩個豆男孩和女孩與許多一對多關係
@ManyToMany(fetch = FetchType.LAZY)
@JoinTable(name = "BOY_GIRL", joinColumns = {@JoinColumn(name = "BOY_ID")}, inverseJoinColumns = {@JoinColumn(name = "GIRL_ID")})
public Set<Girl> getGirls() {
return girls;
}
現在,如何我可以選擇做與查詢HQL,如果我想要得到的名單女孩條件:
where boy_id = (some_boy_id) and START_DATING > (some_timestamp)
是什麼「的男孩的姑娘名單」? –
我的意思是在SQL它應該看起來像 '選擇girl.name,girl.birth從BOY_GIRL 加盟女孩boy_girl.girl_id = girl.id 其中boy_girl.boy_id =(水木清華)和boy_girl.starting_date>(水木清華)' – beshanoe
你可以顯示女孩課的地圖嗎? –