Hi All,
I am having a designation table with d_name as primary key which i am using in user table as foreign key reference .I am using hbm for mapping in designation hbm i have id defined as d_name mapped to database column .I am getting a error saying
"integrity constraint violation(user_designation_fk) parent key not found. "
Where am i going wrong /this error is coming while i am tring to add a user selecting a designation reading from designation table.
user hbm is as below
<hibernate-mapping>
<class name="com.User" table="USER">
<id column="USER_ID" name="id" >
<generator class="assigned">
</generator>
</id>
<property column="d_name" name="dName"/>
</class>
</hibernate-mapping>
designation hbm is as below
<hibernate-mapping>
<class name="com.Designation" table="Designation">
<id column="d_name" name="dName" >
<generator class="assigned">
</generator>
</id>
</class>
</hibernate-mapping>
and code to save is
Session session = HibernateUtil.getSession();
Transaction tx = session.beginTransaction();
session.save(user);
tx.commit();