-->
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.  [ 3 posts ] 
Author Message
 Post subject: Handling mapping tables
PostPosted: Thu Jan 01, 2009 11:24 am 
Newbie

Joined: Thu Jan 01, 2009 10:57 am
Posts: 7
Hi,

Let me come to the problem directly.

I have below tables.
Quote:
sent_mail
mail_id - pk
from_mail_addr_id - fk of mail_addr table
subject

to_mail_addr_list (mapping table)
mail_id - composite pk, fk of sent_mail table
mail_addr_id - composite pk, fk of mail_addr table

mail_addr
mail_addr_id - pk
mail_addr_txt


And, I have below Java Obejcts
Quote:
SentMail
private EmailAddr fromEmailAddr;
private Set<EmailAddr> toEmailAddr;
private String subject

EmailAddr
private String mailAddress;


Here to_mail_addr_list table is just a mapping table which does not represent any Java object. For the above setup i do not know to create hibernate mapping file.
Quote:
If somebody could help with how to handle the to_mail_addr_list mapping table without creating a java object for the mapping table, that should be more than enough.

Expecting your answers. Thanks a lot for your help
Nava


Top
 Profile  
 
 Post subject: Re..
PostPosted: Fri Jan 02, 2009 12:55 am 
Beginner
Beginner

Joined: Wed Nov 26, 2008 1:02 am
Posts: 22
hi,


in SentMail.hbm.xml.write this and check it,no need to create an object

<set name="events" table="PERSON_EVENT">
<key column="mail_id"/>
<one-to-many column="mail_addr_id" class="EmailAddr"/>
</set>

and EmailAddr.hbm.xml same as like any persistent Entity,

hope it solves,dont forget to rate me,

regards


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 02, 2009 10:00 am 
Beginner
Beginner

Joined: Wed Apr 18, 2007 6:17 pm
Posts: 49
Location: Dominican Republic
Hello,

to_mail_addr_list appears to be a many-to-many relationship. You could handle this by mapping any of the sides with the mapping,

From Entity that represents the sent_mail table,

Code:
<set name="addresses" table="to_mail_addr_list">
      <key column="mail_id"/>
      <many-to-many column="mail_addr_id" class="EmailAddrEntity"/>
</set>



Or from the Entity that represents the mail_addr table,

Code:
<set name="emails" table="to_mail_addr_list">
      <key column="mail_addr_id"/>
      <many-to-many column="mail_id" class="EmailEntity"/>
</set>



Regards,


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.