Menu

#446 PostgreSQLOidDataType.setSqlValue casts PGConnection instead of unwrapping

v2.7.*
open-fixed
None
3.0.0
5
2025-06-28
2022-08-05
No

This is similar to issue #436, where PostgreSQLOidDataType.getSqlValue would cast connections to PGConnection directly.

This issue was not fixed in the setSqlValue method, which results in ClassCastExceptions when inserting large objects with a wrapped/proxied connection (e.g. HikariCP).
Example test: https://github.com/kmolski/dbunit-issue-446/blob/main/src/test/java/pl/kmolski/DbunitProxyReproTest.java

The issue could be solved like bug #436, by changing the cast:

LargeObjectManager lobj = ((org.postgresql.PGConnection)
    statement.getConnection()).getLargeObjectAPI();

to unwrap:

PGConnection pgConnection = connection.unwrap(PGConnection.class);
LargeObjectManager lobj = pgConnection.getLargeObjectAPI();

Discussion

  • Jeff Jensen

    Jeff Jensen - 2022-08-05
    • status: open --> open-accepted
    • assigned_to: Jeff Jensen
     
  • Jeff Jensen

    Jeff Jensen - 2022-08-05

    Thank you for reporting with a solution; even better you made a test - very helpful! Thank you very much. Will review and apply this as soon as I can.

     
  • Jeff Jensen

    Jeff Jensen - 2025-06-28
    • status: open-accepted --> open-fixed
    • Fixed Release: (not fixed) --> 3.0.0