-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
java.sql.Wrapper defines ``` <T> T unwrap(java.lang.Class<T> iface) throws java.sql.SQLException; ``` ConnectionPoolDataSourceProxy inherits from DataSourceProxyBase ``` public Object unwrap(Class iface) throws SQLException { return null; } ``` Extending `ConnectionPoolDataSourceProxy` in Scala doesn't work ``` [playframework] [error] /home/jenkins/workspace/scala-2.13.x-integrate-community-build/target-0.9.16/project-builds/playframework-f83a83f4042298df8025a1d271c2e3e565ce83f2/persistence/play-jdbc/src/main/scala/org/jdbcdslog/LogSqlDataSource.scala:16:7: name clash between inherited members: [playframework] [error] def unwrap[T](x$1: Class[T]): T in trait Wrapper and [playframework] [error] def unwrap(x$1: Class[_]): Object in class DataSourceProxyBase [playframework] [error] have same type after erasure: (x$1: Class)Object [playframework] [error] class LogSqlDataSource extends ConnectionPoolDataSourceProxy { [playframework] [error] ^ ``` trying to write `ConnectionPoolDataSourceProxy` doesn't work either, i get basically the same error from javac. So using a different approach, just an accessor for the field. (cherry picked from commit d19c4a2c856b64195454854f6ea33a73165040db)
- Loading branch information
Showing
7 changed files
with
40 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
persistence/play-jdbc/src/main/java/org/jdbcdslog/AccessConnectionPoolDataSourceProxy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
* Copyright (C) 2009-2019 Lightbend Inc. <https://www.lightbend.com> | ||
*/ | ||
|
||
package org.jdbcdslog; | ||
|
||
import javax.sql.DataSource; | ||
|
||
/** | ||
* This class is necessary because ConnectionPoolDataSourceProxy's targetDS field is protected. So | ||
* by defining this helper class, in Java and in the org.jdbcdslog, we can access the protected | ||
* field (because being in the package grants protected access). | ||
*/ | ||
public class AccessConnectionPoolDataSourceProxy { | ||
public static DataSource getTargetDatasource(ConnectionPoolDataSourceProxy p) { | ||
return (DataSource) p.targetDS; | ||
} | ||
} |
22 changes: 0 additions & 22 deletions
22
persistence/play-jdbc/src/main/scala/org/jdbcdslog/LogSqlDataSource.scala
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters