Hello Folks,
I am creating an application that uses hibernate for database design.
There are two tables:
DocumentType and DocBatch
The following are the hbm files for each
<hibernate-mapping package="com.mccamish.domain.mapping">
<class name="DocumentType" table="DOCUMENTTYPE">
<id name="id"
column="DOCTYPEID"
type="long"
unsaved-value="0">
<generator class="native"/>
</id>
<property name="carrier" unique="true"> <column name="CARRIER" sql-type="VARCHAR(50)"/> </property>
<property name="prodId" unique="true"> <column name="PRODID" sql-type="VARCHAR(50)"/> </property>
<property name="srcSysDocId" unique="true"> <column name="SRCSYSDOCID" sql-type="VARCHAR(50)"/> </property>
<property name="srcSystem" unique="true"> <column name="SRCSYSTEM" sql-type="VARCHAR(50)"/> </property>
<property name="docDescription"> <column name="DOCDESCRIPTION" sql-type="VARCHAR(150)"/> </property>
</class>
</hibernate-mapping>
<hibernate-mapping package="com.mccamish.domain.mapping">
<class name="DocBatch" table="DOCBATCH">
<id name="id"
column="DOCBATCHID"
type="long"
unsaved-value="0">
<generator class="native"/>
</id>
<property name="docTypeId"> <column name="DOCTYPEID" sql-type="BIGINT"/></property>
<property name="openInd"> <column name="OPENIND" /></property>
<property name="docBatchConsolidatedFileLoc"> <column name="DOCBATCHCONSOLIDATEDLFILELOC" sql-type="VARCHAR(150)"/></property>
<property name="environment"> <column name="ENVIRONMENT" sql-type="VARCHAR(50)"/></property>
<property name="batchOpen"> <column name="BATCHOPEN" sql-type="DATE"/></property>
<property name="batchClose"> <column name="BATCHCLOSE" sql-type="DATE"/></property>
</class>
</hibernate-mapping>
I would like to define DOCTYPEID in the DocBatch table as a foriegn key having a relationship with the DOCTYPEID column in the DocumentType table.
How can I specify this in the hibernate mapping file?
Can someone point me in the right direction?
Thanks,
Kunal
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
Mapping documents:
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:
Name and version of the database you are using:
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
Problems with Session and transaction handling?
Read this:
http://hibernate.org/42.html
[code][/code]