Get hold of a JDBC Connection object from a Stateless Bean

后端 未结 7 1840
孤街浪徒
孤街浪徒 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:10

    You must take the underlying delegate using entitymanager.getDelegate() or entitymanager.unwrap(which is the better way), cast it to the specific implementation(in Hibernate it is called Session). Then you can call the connection() method. Be aware this is deprecated, use the Work class instead. Read more here.

提交回复
热议问题