1
我一直在遇到JPA關閉連接問題。我使用Spring 3.0.5與休眠3.0。我正在使用JPA事務管理器來管理我的服務並使用必需的傳播。 JPA轉換管理器關閉連接問題
這是我的場景。
Table A
id
desc (LAZY)
Table B
a_id
a_id in Table B refers to id of Table A.
我要加載的實體給定的實體B.
Here is what I am doing (roughly) inside the controller:
List<B> list = serviceB.find() ;
for each element - itemB in above list : itemA = serviceA.find(itemB.a_id);
convert itemA to UI bean and set it in model.
我假設每個發現的()在我的服務方法將在事務內執行,憑藉着必需的傳播。然而,對於第二個find()它會拋出異常,並且這也是間歇性的。有時它說CLOSED連接,並在其他時間它說'交易不活躍',奇怪的是有些其他時間它按預期工作!讓我瘋狂..
幫助感謝!