-->
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.  [ 2 posts ] 
Author Message
 Post subject: need help with mapping.
PostPosted: Thu Aug 14, 2008 3:58 am 
Newbie

Joined: Thu Aug 14, 2008 3:42 am
Posts: 1
Location: India
Following are the tables with relationship


tbl_spot_media
___________________
spot_media_id
spot_id
cmedia_id
description
--------------------------
* Above table associates with cmedia_id with spot



tbl_spot_media_video_format
___________________
video_format_id
video_type
min_video_size
max_video_size
spot_media_id
description
--------------------------
* Above table contains multiple entry for video format associated with spot_media_id


tbl_spot_media_video_format
___________________
image_format_id
img_type
height
width
spot_media_id
description
--------------------------
* Above table contains multiple entry for video format associated with spot_media_id


I need to define a class like SpotMedia with

class SpotMedia {

//that returns values associated with spot media either of audio or video format
Set/List getMediaFormats()
{ }
}



class AudioFormat{}
class VedioFormat{}


Any suggestion on implementing above. I can create view/or any other intermediate class/table required.


Top
 Profile  
 
 Post subject: it's not that much of a deal
PostPosted: Thu Aug 14, 2008 4:53 am 
Newbie

Joined: Mon Jul 30, 2007 5:03 am
Posts: 8
First ,

if you use Eclipse IDE , you can install the Hibernate plugin and do a reverse engineer on the database .This will automatically create the POJOs and the mapping files for you .


http://www.hibernate.org/hib_docs/tools ... ugins.html


if this is not the case , let me see if i get it right :


you have two tables with the same name , so i'm going to try and map only the first and second table , the third should be the same thing :


you have a one to many relationship between tbp_spot_media -> tbl_spot_media_video_format with the foregin key column spot_media_id



Code:

      <set name="spotMediaVideoFormats" inverse="true" >
         <key>
            <column name="spot_media_id" not-null="false"/>
         </key>
         <one-to-many class="xx.yyy.zzz.SpotMediaVideoFormat" />
      </set>



and in the SpotMediaVideoFormat.hbm.xml you should have something like this :

Code:
<many-to-one name="adresa" class="xx.yyy.zzz.SpotMedia">
           <column name="spot_id"/>
        </many-to-one>



hope it helps .
Victor[/code]


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.