-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Query Regarding Mapping between Tables
PostPosted: Thu Jan 24, 2008 9:19 am 
Newbie

Joined: Thu Jan 24, 2008 9:06 am
Posts: 2
I am somewhat confused about the mapping between two tables through Hibernate. My requirement is as follows:
I have two tables A and B.

A has two fields ( contentid , name) where as B has ( id, contentid, name, name2).

Now what i want is that when I update/insert in the table A, that should be automatically inserted/updated in table B.

I had tried all the combinations which are there in hibernate tutorials but not working properly, Can any one help in making the correct mapping files/classes for the aabove scenario.
Thanks in advance

_________________
Khajan Joshi


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 24, 2008 11:56 am 
Expert
Expert

Joined: Mon Nov 26, 2007 2:29 pm
Posts: 443
What are the primary keys of both tables?
Do they share a PK? Is there only one or many Bs for every A?
Do you want the nformation on both tables to be part of a single class, or two classes?

_________________
Gonzalo Díaz


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 25, 2008 12:46 am 
Newbie

Joined: Thu Jan 24, 2008 9:06 am
Posts: 2
The content id is the key common between both the tables , and i want info on both the tables and how if we update table A , B should also get automatically updated

_________________
Khajan Joshi


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 25, 2008 12:57 am 
Expert
Expert

Joined: Mon Nov 26, 2007 2:29 pm
Posts: 443
In that case, use the "one-to-one relationship by a primary key", described in the reference documentation (7.2.2. one to one, second example).

_________________
Gonzalo Díaz


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.