• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Extra column created

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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>
 
Ranch Hand
Posts: 662
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic