Merge pull request #274 from tedeling/2.3.x

Unwrap ConnectionProvider to DataSource
pull/284/head
Brett Wooldridge 10 years ago
commit e9e7f05c42

@ -31,6 +31,8 @@ import org.slf4j.LoggerFactory;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import javax.sql.DataSource;
/**
* Connection provider for Hibernate 4.3.
*
@ -125,11 +127,15 @@ public class HikariConnectionProvider implements ConnectionProvider, Configurabl
@SuppressWarnings("unchecked")
public <T> T unwrap(Class<T> unwrapType)
{
if (isUnwrappableAs(unwrapType)) {
if ( ConnectionProvider.class.equals( unwrapType ) ||
HikariConnectionProvider.class.isAssignableFrom( unwrapType ) ) {
return (T) this;
}
else if ( DataSource.class.isAssignableFrom( unwrapType ) ) {
return (T) this.hds;
}
else {
throw new UnknownUnwrapTypeException(unwrapType);
throw new UnknownUnwrapTypeException( unwrapType );
}
}

Loading…
Cancel
Save