Some things about your code...
Code:
SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
Session session = sessionFactory.openSession();
// 1.) This does not work. You'll have to use new Long(92), Long.valueOf(92) [Java 1.5] or whatever. Anyway you need a Serializable object
// 2.) Better: Use session.load(...), cause you assume that the object exists and non-existence would be an actual error (see JavaDoc e.g.). session.get(..) might return NULL which would lead to a NullPointerException.
Category category = (Category) session.get(Category.class, 92);
category.setName("CCC");
Transaction transaction = session.beginTransaction();
transaction.commit();
session.close();
Use:
Code:
SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
Session session = sessionFactory.openSession();
Transaction transaction = session.beginTransaction();
Category category = (Category) session.load(Category.class, new Long(92));
category.setName("CCC");
transaction.commit();
session.close();
Best regards
Sven