Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PAYARA-2267 JPA Conversion now unwraps connection properly #2279

Merged
merged 3 commits into from Mar 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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