-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Child records are deleting automatically after redeploying
PostPosted: Wed May 26, 2010 3:55 pm 
Newbie

Joined: Wed May 26, 2010 3:41 pm
Posts: 1
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.