I did followed this discussion about this, but there's not a clear answer. The best supposition argues that it's a much clearer DB design to use a join table but this surely doesn't explain why this is a strong recommendation.
It's a very interesting question. If anyone knows anything more, please do share. I'm very curious.
Check the Hibernate documenatation once again. In the many-to-one and one-to-many chapters carefully compare the mapping scheme with the create statements.
Do you see? Intuitively (and in real world) an address belongs to a person and not the reversed way. The same story goes on for many other cases. If you want to link the address with one or more persons using a key anyway, then you better need a join table so that you still can get the address by person. [ December 25, 2008: Message edited by: Bauke Scholtz ]
But if we have tables called ORDER and ORDER_FEATURES, then ONE-TO-MANY with a Foreign Key is a valid scenario. Here, the Foreign key column called ORDER_NUMBER will be in ORDER_FEATURES, referring to ORDER_NUMBER in ORDER table. It would be Uni-Directional because the Order features do not have any menaing by themselves; they make sense only when they are embeded as part of the order object. We do have some situations of this type. So, I am not sure why this is referred as a very unusual case. Kindly explain if I am wrong.
Sunil Kumar Roy
Greenhorn
Joined: Dec 31, 2008
Posts: 2
posted
0
Actually, I am facing a Mapping issue with one-to-many association on a foreign key. Requesting Help.
In Table ACTIVITY, BUSNS_ACTVY_ID is the PK.
In Table ACTIVITY_SERVICE_ATTRIBUTE, SRVC_ATTRIB_BUSNS_ACTVY_ID is the FK, referring to BUSNS_ACTVY_ID in ACTIVITY.
[ERROR] Repeated column in mapping for entity: com.custom.businessclasses.ActivityServiceAttribute column: SRVC_ATTRIB_BUSNS_ACTVY_ID (should be mapped with insert="false" update="false") [/ERROR]
I m too stuck on the issue particulary stated by Sunil Kumar Roy. If I add insertable and updatable false in my child entity, I wont be able to save it separately, which is also very much valid in my case, given I alredy have order_id with me.
If somebody already has a solution for the problem please help or guide to proper forum.