Mercurial > dive4elements > river
changeset 5590:b75005269a6c
Datacage: Fix potential connection leak to SedDB.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Mon, 08 Apr 2013 12:07:43 +0200 |
parents | 1827798ca53f |
children | e4a59c795ff6 |
files | flys-artifacts/src/main/java/de/intevation/flys/artifacts/datacage/Recommendations.java |
diffstat | 1 files changed, 22 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/datacage/Recommendations.java Mon Apr 08 11:24:39 2013 +0200 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/datacage/Recommendations.java Mon Apr 08 12:07:43 2013 +0200 @@ -20,6 +20,7 @@ import org.w3c.dom.Node; import org.hibernate.Session; +import org.hibernate.SessionFactory; import org.hibernate.jdbc.Work; @@ -29,7 +30,7 @@ import de.intevation.flys.artifacts.FLYSArtifact; -import de.intevation.flys.backend.SedDBSessionHolder; +import de.intevation.flys.backend.SessionFactoryProvider; import de.intevation.flys.backend.SessionHolder; import de.intevation.artifactdatabase.data.StateData; @@ -218,26 +219,33 @@ (Connection)null); } }); - /* systemSession.doWork(new Work() { @Override public void execute(final Connection systemConnection) throws SQLException { - SedDBSessionHolder.HOLDER.get().doWork(new Work() { - @Override - public void execute(Connection sedDBConnection) - throws SQLException - { - recommend( - parameters, userId, result, - systemConnection, - sedDBConnection); - } - }); + SessionFactory sedDBFactory = + SessionFactoryProvider.getSedDBSessionFactory(); + + Session sedDBSession = sedDBFactory.openSession(); + try { + sedDBSession.doWork(new Work() { + @Override + public void execute(Connection sedDBConnection) + throws SQLException + { + recommend( + parameters, userId, result, + systemConnection, + sedDBConnection); + } + }); + } + finally { + sedDBSession.close(); + } } }); - */ } public void recommend(