-->
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: Mapping strategy:simple association 1class 4 muiltipl tables
PostPosted: Fri Jun 03, 2005 11:08 am 
Newbie

Joined: Thu May 26, 2005 1:04 pm
Posts: 13
I have two tables
Table 1 -> JOB (job_uid,jobname,assigned_user_id,modifyon,modifyby)
Table 2 : JOB_SAMPLE (jobsample_uid,job_uid,sample_uid)

Where sample is another persistent class.

I was trying to do a Single class for these two tables.

Q1. Is it a good practice to map a single class to muiltiple tables?
Q2. If not any alternate suggestions would be helpful.

Pardon me if its sounds trivial but I am a new bie to ORM.



Hibernate version:3.05

Mapping documents:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="my.app.domain.Job" table="JOB">
<id name="jobUid" column="JOB_UID" type="java.lang.Long">
<generator class="native"/>
</id>
<timestamp column="_MODIFY_ON" name="ModifyOn"/>
<property name="jobName" column="JOB_NAME" type="java.lang.String"
length="50"/>
<!-- associations -->
<many-to-one name="ModifiedBy" column="_MODIFIED_BY"
class="my.app.domain.UserProfile" cascade="none"/>
<many-to-one name="assignedUser" column="ASSIGNED_USER_UID"
class="my.app.domain.UserProfile" cascade="none"/>
<!--collections-->
<set name="samples" table="JOB_SAMPLE" cascade="all-delete-orphan">
<key column="JOB_UID"/>
<many-to-many column="SAMPLE_UID"
class="my.app.domain.Sample" />
</set>
</class>
</hibernate-mapping>

_________________
RT


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.