PostgreSQLOidDataType casts statement.getConnection() to an instance of PGConnection. It should use statement.getConnection().unwrap(PGConnection.class) instead. The cast will fail if there are intermediate connection wrappers involved (such as DBCP2).
From:
LargeObjectManager lobj = ((org.postgresql.PGConnection)
statement.getConnection()).getLargeObjectAPI();
To:
LargeObjectManager lobj = statement.getConnection().unwrap(org.postgresql.PGConnection.class)
.getLargeObjectAPI();
See https://github.com/database-rider/database-rider/issues/253, the issue has been resolved by unwrapping the connection in
rider-cdiThank you for the report and fix.
If you have a test for this, would greatly appreciate your contribution on that too.
Looks like this issue is still present in PostgreSQLOidDataType#setSqlValue(): https://sourceforge.net/p/dbunit/code.git/ci/master/tree/src/main/java/org/dbunit/ext/postgresql/PostgreSQLOidDataType.java#l93
Last edit: Krzysztof Molski 2022-07-26