Transaction in Hibernate

in utopian-io •  7 years ago 

Session session = null;
Transaction tx = null;
try {
session = sessionFactory.openSession();
tx = session.beginTransaction();
Query update = session.createSQLQuery("update User set username='XYZ' where userid=123");
update.executeUpdate();
tx.commit();
} catch (Exception e) {
tx.rollback();
} finally {
session.close();
}



Posted on Utopian.io - Rewarding Open Source Contributors

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Your contribution cannot be approved because it does not follow the Utopian Rules, and is considered as spam.

You can contact us on Discord.
[utopian-moderator]