Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/datacage/Recommendations.java @ 9272:1d59da89b00d
Fixed: fix_analysis_year function fo datacage closed current database connection.
building datacage now wrapepd in transaction
author | gernotbelger |
---|---|
date | Thu, 19 Jul 2018 16:37:04 +0200 |
parents | 5030c46d8cb4 |
children |
comparison
equal
deleted
inserted
replaced
9271:f48a8dc78529 | 9272:1d59da89b00d |
---|---|
27 import org.w3c.dom.Document; | 27 import org.w3c.dom.Document; |
28 import org.w3c.dom.Node; | 28 import org.w3c.dom.Node; |
29 | 29 |
30 import org.hibernate.Session; | 30 import org.hibernate.Session; |
31 import org.hibernate.SessionFactory; | 31 import org.hibernate.SessionFactory; |
32 | 32 import org.hibernate.Transaction; |
33 import org.hibernate.jdbc.Work; | 33 import org.hibernate.jdbc.Work; |
34 import org.dive4elements.artifacts.CallContext; | 34 import org.dive4elements.artifacts.CallContext; |
35 import org.dive4elements.artifacts.common.utils.Config; | 35 import org.dive4elements.artifacts.common.utils.Config; |
36 import org.dive4elements.artifacts.common.utils.XMLUtils; | 36 import org.dive4elements.artifacts.common.utils.XMLUtils; |
37 import org.dive4elements.artifacts.common.utils.StringUtils; | 37 import org.dive4elements.artifacts.common.utils.StringUtils; |
214 public void recommend( final Map<String, Object> parameters, final String userId, final Node result, final CallContext context ) { | 214 public void recommend( final Map<String, Object> parameters, final String userId, final Node result, final CallContext context ) { |
215 recommend(parameters, userId, result, SessionHolder.HOLDER.get(), context); | 215 recommend(parameters, userId, result, SessionHolder.HOLDER.get(), context); |
216 } | 216 } |
217 | 217 |
218 public void recommend( final Map<String, Object> parameters, final String userId, final Node result, final Session systemSession, final CallContext context ) { | 218 public void recommend( final Map<String, Object> parameters, final String userId, final Node result, final Session systemSession, final CallContext context ) { |
219 | |
220 // REMARK: we star a transaction here, because some code (specificely FixAnalysisYearXPathFunction) will execute hibernate queries without directly using the given connection | |
221 // This will the current connection getting closed, if we are no inside a transaction. | |
222 final Transaction transaction = systemSession.beginTransaction(); | |
223 | |
219 systemSession.doWork(new Work() { | 224 systemSession.doWork(new Work() { |
220 @Override | 225 @Override |
221 public void execute(final Connection systemConnection) | 226 public void execute(final Connection systemConnection) |
222 throws SQLException | 227 throws SQLException |
223 { | 228 { |
238 finally { | 243 finally { |
239 sedDBSession.close(); | 244 sedDBSession.close(); |
240 } | 245 } |
241 } | 246 } |
242 }); | 247 }); |
248 | |
249 transaction.commit(); | |
243 } | 250 } |
244 | 251 |
245 public void recommend( | 252 public void recommend( |
246 final Map<String, Object> parameters, | 253 final Map<String, Object> parameters, |
247 final String userId, | 254 final String userId, |