I am using Hibernate 3.6.7 (Core) and I am using XML Configuration.
I have One Company Master and its Branch Master table. The relation is 1 to many in it. My requirement is when I am inserting the data to Company Master I am getting list of Branches too.
In configuration file, I have defined it
<set name="branches" table="m_company_branch"
inverse="true" lazy="true" fetch="select" cascade="all">
<key>
<column name="company_id" not-null="true" />
</key>
<one-to-many class="com.my.CompanyBranchStructure" />
</set>
When I am inserting to the table, it only inserts to primary table i.e m_company but not committed. However, I have passed the list of branches too. and hence I am getting an error "Batch update returns....." since it is not getting the company_id (foreign key of branch).
After reading some contents on Internet, I got to know that I need to do separate Insert/Commit transaction for the purpose.
But then I am unable to understand the mapping in configuration file.
As it treats each table (record) separately, I can do the same without using one-to-many or many-to-many relations too.
Kindly guide.