public static void updateUser(){
Session session = null;
try {
session = HibernateUtil.getSessionFactory().openSession();
session.beginTransaction();
User user = (User)session.get(User.class, new Integer(5)); //get item according id
user.setLastName("Změněný");
session.update(user);
session.getTransaction().commit();
} catch (HibernateException he) {
session.getTransaction().rollback(); //roll back
he.printStackTrace();