Hi Friends please help me. I am getting strange issue.
cityBean is parent class and RvBoardingPointM is child table. one-to-many mapping between cityBean and RvBoardingPointM .
Following code is for saving parent and child records.
RvCityM cityBean = new RvCityM(); cityBean.setName("Testing"); cityBean.setCreatedDate(new Date()); cityBean.setStatus('A');
Set<RvBoardingPointM> points = new HashSet<RvBoardingPointM>(); RvBoardingPointM point1 = new RvBoardingPointM(); point1.setName("Test1"); point1.setRvCityM(cityBean);
RvBoardingPointM point2 = new RvBoardingPointM(); point2.setName("Test1"); point2.setRvCityM(cityBean);
List list = boardingTable.getData();
cityBean.setRvBoardingPointMs(points);
Session session = getSession(); Transaction transaction = session.beginTransaction(); try{ getHibernateTemplate().saveOrUpdate(cityBean); getHibernateTemplate().saveOrUpdateAll(points); transaction.commit(); }catch(Exception e){ transaction.rollback(); throw e; }
the above code is successfully saving records. I can able to see the records from backend.
Strange thing is that, if I redeploy the code, child records are removing on server startup, but parent records are remain.
Please help me on this.
|