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