TransactionAwareDataSourceProxy locally handles get/clearWarnings call

Closes gh-23346
This commit is contained in:
Juergen Hoeller 2019-08-01 15:26:00 +02:00
parent aebc485eda
commit 871bb57e02
1 changed files with 5 additions and 1 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -203,6 +203,10 @@ public class TransactionAwareDataSourceProxy extends DelegatingDataSource {
return true;
}
}
else if (method.getName().equals("getWarnings") || method.getName().equals("clearWarnings")) {
// Avoid creation of target Connection on pre-close cleanup (e.g. in Hibernate Session)
return null;
}
else if (method.getName().equals("close")) {
// Handle close method: only close if not within a transaction.
DataSourceUtils.doReleaseConnection(this.target, this.targetDataSource);