-->
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.  [ 1 post ] 
Author Message
 Post subject: working with one-to-many relationship.i'm stacked somewhere
PostPosted: Tue Jul 21, 2009 8:41 am 
Newbie

Joined: Mon Mar 30, 2009 2:47 pm
Posts: 15
Hello good people. I know the kind of help and understanding i'm about to request for might look trivail for you gurus but i'm just getting my hands on hibernate and i'm a complete newbie.Well that said i'm trying to understand hibernate by doing a small project for myself.I have 2 tables : message (messageId, text, commaseprecipnums, date) and log table (id, messageid, recipientnumber, smsstatus)
as you can see lod hold the relationship by having a reference to messageId which is the primary key of message table.
I get my configuration working and can insert correctly in message table.
Now before i continue, i believe that here is one to many(many to one) relationship between them since there is a single unique message sent to one or multiple recipients.(correct me if i'm wrong)
here are relationship part snippet of my hbm.xml files
message.hbm.xml
Code:
<set name="logdetails">
  <key column="messageId"/>
  <one-to-many class="Domain.Log"/>
</set>

log.hbm.xml
Code:
<many-to-one class="Domain.Users" name="messageId"/>

Now what i want to achieve is to insert to log the same time as i save a message object.I came up with an idea about using transaction where i save the message object and return the last inserted id and then save the log object.but i'm using dao's and i can't use log dao object inside message dao.So how can i achieve that.Thanks for reading.and thanks for the help


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

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.