Enabling AvailableSettings.ENABLE_LAZY_LOAD_NO_TRANS results in leaking DB-connections
Description
Attachments
caused by
is followed up by
Activity

Stephan van Hugten December 12, 2013 at 2:49 PM
Problem might still exist in 4.2.7.SP1. See HHH-8782.

万纪东 October 24, 2013 at 10:51 AM
hibernate-core-4.2.6.Final.jar,hibernate-entitymanager-4.2.6
This problem also occurs, the next version will fix this problem it?

Vladimír Kuruc August 28, 2013 at 6:28 AM
Sorry, I am unable to attach patched test case. So I add in only in text.
Eclipse Workspace Patch 1.0
#P hibernate-core
diff --git src/test/java/org/hibernate/test/ondemandload/Inventory.java src/test/java/org/hibernate/test/ondemandload/Inventory.java
index 494df13..b475d37 100644
src/test/java/org/hibernate/test/ondemandload/Inventory.java
+++ src/test/java/org/hibernate/test/ondemandload/Inventory.java
@@ -36,7 +36,7 @@
@Entity
public class Inventory {
private int id = -1;
- private Store store;
+ //private Store store;
private Product product;
private Long quantity;
private BigDecimal storePrice;
@@ -45,7 +45,7 @@
}
public Inventory(Store store, Product product) {
- this.store = store;
+ //this.store = store;
this.product = product;
}
@@ -60,7 +60,7 @@
this.id = id;
}
- @ManyToOne
+ /*@ManyToOne
@JoinColumn( name = "store_id" )
public Store getStore() {
return store;
@@ -69,7 +69,7 @@
public Inventory setStore(Store store) {
this.store = store;
return this;
- }
+ }*/
@ManyToOne
@JoinColumn( name = "prod_id" )
diff --git src/test/java/org/hibernate/test/ondemandload/Store.java src/test/java/org/hibernate/test/ondemandload/Store.java
index d2c1eb1..ba154d6 100644
— src/test/java/org/hibernate/test/ondemandload/Store.java
+++ src/test/java/org/hibernate/test/ondemandload/Store.java
@@ -68,7 +68,8 @@
return this;
}
- @OneToMany(mappedBy = "store", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
+ //@OneToMany(mappedBy = "store", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
+ @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, orphanRemoval = true)
public List<Inventory> getInventories() {
return inventories;
}

Vladimír Kuruc August 28, 2013 at 6:23 AM
Hi Steve,
I still have leaking connections when I have unidirectional one to many collection with orphan removal. Please run modified LazyLoadingTest test case to reproduce this situation.
log:
ERROR AssertionFailure:43 - HHH000099: an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session): org.hibernate.AssertionFailure: collection owner not associated with session: org.hibernate.test.ondemandload.Store.inventories
WARN AbstractPersistentCollection:246 - Unable to close temporary session used to load lazy collection associated to no session

Andreas Joseph Krogh August 16, 2012 at 9:09 PM
Thanks for fixing!
Details
Details
Assignee
Reporter

When enabling ENABLE_LAZY_LOAD_NO_TRANS it seems Hibernate doesn't close the SQL-Connection proparly resulting in connection-pool starvation.
I haven't got a test-case yet but I've confirmed the behavior in two separate environments. Will provide a test-case if necessary.