Skip to content

Commit

Permalink
Merge pull request #2279 from Cousjava/PAYARA-2267-timestamp-jpa
Browse files Browse the repository at this point in the history
PAYARA-2267 JPA Conversion now unwraps connection properly
  • Loading branch information
Pandrex247 committed Mar 5, 2018
2 parents ebae263 + 9f74c91 commit 5f04340
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Expand Up @@ -37,6 +37,7 @@
* only if the new code is made subject to such option by the copyright
* holder.
*/
// Portions Copyright [2018] Payara Foundation and/or affiliates

package com.sun.gjc.spi.base;

Expand Down Expand Up @@ -130,9 +131,11 @@ public ConnectionHolder(Connection con, ManagedConnectionImpl mc,
* Returns the actual connection in this holder object.
*
* @return Connection object.
* @throws java.sql.SQLException
*/
public Connection getConnection() {
return con;
public Connection getConnection() throws SQLException {
//To ensure that the actual connection is always returned and not a proxy
return con.unwrap(java.sql.Connection.class);
}

/**
Expand Down
Expand Up @@ -493,10 +493,12 @@ public Struct createStruct(String typeName, Object[] attributes) throws SQLExcep
* @throws java.sql.SQLException If no object found that implements the interface
* @since 1.6
*/
@Override
public <T> T unwrap(Class<T> iface) throws SQLException {
checkValidity();
T result = null;
if (iface.isInstance(this)) { //if iface is "java.sql.Connection"

result = iface.cast(this);
} else if (iface.isInstance(con)) {
//if iface is not "java.sql.Connection" & implemented by native Connection
Expand Down

0 comments on commit 5f04340

Please sign in to comment.