-->
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: Giving same persistent object to two sessions in one trasn.
PostPosted: Fri Sep 17, 2004 5:40 am 
Newbie

Joined: Thu Aug 12, 2004 10:02 am
Posts: 8
Hibernate version:
Hibernate 2.1.4

Name and version of the database you are using:
Informix Dynamic Server 9.4

Issue

In my application i am updating two databases of same schema with separate sessions for each. Can i give the same persitent object for the two sessions. I am using the XA datasources. The function i am using is given below.

private Collection createMethod(Collection beans) throws MyException {
//Getting the session bean object
Session session = getSession(1);
Session session2 = getSession(2);
Vector ret = new Vector();

if (beans.size() == 0)
return ret;

Iterator itr = beans.iterator();
Object obj = null;
try {

while (itr.hasNext())
{
obj = itr.next();
session.save(obj);
session2.save(obj);
ret.add(obj);
}
log.info("Records saved Successfully");
return ret;

} catch (HibernateException e) {
handleException(new MyException(e));
}
return new Vector();
}

Is there anything wrong with this? Anyway this is working for me.

_________________
amritkumar


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.