Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Extra column created

 
ramji srinivasan
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Iam having two tables

1. Subjects table with fields (SUB_NAME(pk),SUB_DURATION,SUB_STREAM).
2. Cources table with fields (COURSE_ID(pk),COURSE_NAME,COURSE_FACULTY)

Iam having a many to one mapping between SUB_NAME and COURSE_NAME.

but when i create tables using hibernate SUB_NAME column is created in both the tables. How can we avoid this?

This is the mapping files for two tables:

Subjects:

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"D:\Softwares\DTD\hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.patni.hibernatesample.forms.ContactForm" table="HSUBJECTS">
<id name="name" column="SUB_NAME"/>
<property name="duration">
<column name="SUB_DURATION" />
</property>
<property name="stream">
<column name="SUB_STREAM"/>
</property>
</class>
</hibernate-mapping>

Courses:

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"D:\Softwares\DTD\hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.patni.hibernatesample.forms.CoursesForm" table="HCOURSES">
<id name="courseId" column="COURSE_ID"/>
<property name="courseName">
<column name="COURSE_NAME" />
</property>
<many-to-one name="Hsubjects" class="com.patni.hibernatesample.forms.ContactForm" column="SUB_NAME"/>
<property name="faculty">
<column name="COURSE_FACULTY"/>
</property>
</class>
</hibernate-mapping>
 
Arun Kumarr
Ranch Hand
Posts: 661
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<many-to-one name="Hsubjects" class="com.patni.hibernatesample.forms.ContactForm" column="SUB_NAME"/>


why do you have this foreign key mapping here for SUB_NAME?
No wonder they are getting generated.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic