Session session = sessionFactory.openSession(); Transaction transaction = session.beginTransaction(); // code to be executed during the transaction ... transaction.commit(); session.close();In this example, we start a transaction using the `beginTransaction()` method and then execute some code. After the code has been executed, we call the `commit()` method to save the changes to the database. Package Library: The package for this library is `org.hibernate`.