简体   繁体   English

连接池配置是否保留在JPA上下文之外?

[英]Is the connection Pool configuration kept outside JPA Context?

Hello i am extracting the connection object from the EclipseLink context by calling: Connection con = entityManager.unwrap(Connection.class); 您好,我正在通过调用以下方法从EclipseLink上下文中提取连接对象:Connection con = entityManager.unwrap(Connection.class);

i am responsible for releasing the Connection in order it to comeback into the pool however i need to know if the extracted connection is supposed to keep the original configuration set by EclipseLink i mean number of connections, Maximum number of connections and so on..if so then once it is returned into EclipseLink it is supposed to keep the same performance than working normally.. 我负责释放Connection以便使其重新回到池中,但是我需要知道提取的连接是否应该保持EclipseLink设置的原始配置,我的意思是连接数,最大连接数等等。因此,一旦将其返回到EclipseLink,它应该保持与正常工作相同的性能。

i need to know this cause maybe the experience of someone can help me in choosing if getting the connection in this way will keep a good performance as EclipseLink does when working its native JPA, thanks in advance.. 我需要知道这个原因,也许有人的经验可以帮助我选择是否以这种方式获得连接将像EclipseLink在其本机JPA上所做的那样保持良好的性能,在此先感谢。

You can only unwrap the Connection in the scope of a transaction. 您只能在事务范围内展开连接。 So you will get the same connection that the EntityManager is bound to (from the pool). 因此,您将(从池中)获得与EntityManager绑定到的相同连接。 You must not release this connection, EclipseLink will release when the transaction ends. 您不得释放此连接,事务结束时EclipseLink将释放。

So, to be clear, you are NOT responsible for releasing the connection. 因此,很明显,您不负责释放连接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM