I use a Hibernate session in a MBean method in the following way:
InitialContext context = new InitialContext(); SessionFactory factory = (SessionFactory) context.lookup(SESSION_FACTORY_JNDI_NAME); session = factory.openSession(); Transaction tx = session.beginTransaction(); try { MyDAO o = (MyDAO) session.load(MyDAO.class, "key1", LockMode.UPGRADE); .... tx.commit(); } catch (Exception e) { tx.rollback(); }
Moderated: Hibernate questions are not answered in the jca forum.