[英]Default fetch type for one-to-one, many-to-one and one-to-many in Hibernate
[英]Hibernate one-to-one and one-to-many
我目前在2個表之間有一對多關系:我有:
Table A (id, ...)
Table B (tableAId, ...) (has no id of it's own).
在映射中,這是使用<list>完成的。
我遇到的問題是,我必須從A到B添加另一個一對一的關系。
class A {
public B b; // new part
public List<B> bs; // already existing part.
}
我在表中有一個布爾列,通過該列我應該區分一對一和一對多。 我不確定如何為這些表編寫休眠映射。 你們中的任何一個都可以幫我嗎?
我認為您可以通過使用“ mappedBy”來做到這一點,您是否嘗試過?
http://docs.jboss.org/hibernate/annotations/3.5/reference/en/html_single/#entity-mapping-association
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.