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
|