I am trying to insert data to the DB using hibernate . Here is how I going perform that action
session.beginTransaction();
pojo.StuDetails stu = new
In your SubjectHasStuDetials.hbm.xml
make these changes :
<many-to-one name="stuDetails" class="pojo.StuDetails" fetch="select" cascade="all">
<column name="stu_details_id" not-null="true" />
</many-to-one>
<many-to-one name="subject" class="pojo.Subject" fetch="select" cascade="all" >
<column name="subject_id" not-null="true" />
</many-to-one>
Add cascade="all"
attribute to both stuDetails
and subject
many-to-one tags.
cascade = “all”
then changes at parent class object will
be effected to child class object too, if we write cascade = “all”
then all operations like insert, delete, update at parent object will
be effected to child object also.