-->
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: Question on tx.commit() and tx.rollback()
PostPosted: Fri Jun 23, 2006 10:01 am 
Newbie

Joined: Thu Jun 08, 2006 3:25 pm
Posts: 5
Location: Laureldale, PA
Hi All,
On queries that only return data and do not save, update, or delete data, is it nessacary to do a tx.rollback() in the catch section if the createQuery or tx.commit() fail.
Also, It is my understanding that tx.commit() is required on read only queries, because it cause a sync between the database and the session. Is this correct?

Thanks,
Ron

Hibernate version:3

Code between sessionFactory.openSession() and session.close():
Session session = HibernateSessionFactory.currentSession();
Transaction tx = session.beginTransaction();
ContactInfo contact = null;

try{
contact = (ContactInfo) session.createQuery("from ContactInfo a where a.login =:userLogin")
.setString("userLogin", userlogin)
.uniqueResult();
tx.commit();
}catch(Exception e){
System.err.println("ERROR: Exception in getContactInfo(String) at session.createQuery. Details: "+e);
}finally{
HibernateSessionFactory.closeSession();
}

Name and version of the database you are using:
mySql 5


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.