Get hold of a JDBC Connection object from a Stateless Bean

后端 未结 7 1820
孤街浪徒
孤街浪徒 2020-12-09 18:43

In a Stateless Session Bean an EntityManager is injected but I would like to get hold of a Connection object in order to invoke a DB Procedure. Is

7条回答
  •  执念已碎
    2020-12-09 19:14

    This works awesomely and you can use the connection object elsewhere if needed

    SessionImpl sessionImpl = (SessionImpl) session;
    Connection conn = sessionImpl.connection();
    

    Where session is the name of the Hibernate Session object

提交回复
热议问题