• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

mapping three tables

 
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Friends,

I am new to ORM/hibernate please help in this.

I have the follwoing table structure.

Table_A: (a_Id [PK], a_Desc)
Table_B: (b_Id [PK],b_Desc)

These two tables hbm files are working fine.

Now I want to have a mapping table description as below.

Table_Mapping( b_Id [PK], a_Id, mapping_Desc)

Here I want B table primery key b_Id as forieng key to Table_Mapping. And when an entry in Table_Mapping is removed it should not effect any way in either of A and B tables.

Please help in this.

I have found some example on google, but they say keep an instance of Table_Mapping entry in Table_B.hbm, But why like that.

It is all mapping table have reference of other two tables, these two tbales do not know any thing about Mapping. I think they need not to know.

Please help me to understand this, if am wrong.

I appreciate a quick response.

Thanks in advance.
 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It will be better if you can provide relation between objects A,B and Mapping.
for A and B,


what about third one?
 
sammeta Phanikumar
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Ravi for your reply,

Here are the details.



These two classes are working fine because there are opereated independent.

Now I want a third class Mapping. Relation between A and B are: A -> B(many to one) and B->A(One to One)

class Mapping
{
int a_Id;
int b_Id;
String mapping_Desc;
}

I want add/deletion in Mapping table should not reflect in either of Table A and B.
But for any entry in Mapping then Mapping->a_Id ,a_Id should be in Table_A and Mapping->b_Id ,b_Id should be in B table.

Please reply.

 
sammeta Phanikumar
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Please reply any one, if the problem is not clear, let me know i will explain.

 
reply
    Bookmark Topic Watch Topic
  • New Topic