You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm submitting a ... (I am not sure whether this is currently supported or not, but i'll put it as a feature request for now)
bug report
feature request
Describe the issue
A clear and concise description of what the issue is.
Driver Version? --> 42.2.12
Java Version? --> openjdk version "11.0.7" 2020-04-14
OS Version? --> Debian 10.4
PostgreSQL Version? --> PostgreSQL 11.7 (Debian 11.7-0+deb10u1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit
To Reproduce
Steps to reproduce the behaviour: --> Run TestSql.java (JUnit)
Expected behaviour (byte[][]) rs.getArray("children_bytesarr").getArray() should work, just like (String[]) rs.getArray("children_names").getArray(), but it throws error instead.
The complete ddl, source code is provided below.
Logs
The error:
java.lang.ClassCastException: class [Ljava.lang.Object; cannot be cast to class [[B ([Ljava.lang.Object; and [[B are in module java.base of loader 'bootstrap')
at test.TestSql.lambda$1(TestSql.java:116)
at org.jdbi.v3.core.result.ResultSetResultIterator.next(ResultSetResultIterator.java:83)
at org.jdbi.v3.core.result.ResultIterable.one(ResultIterable.java:138)
at test.TestSql.lambda$0(TestSql.java:118)
at org.jdbi.v3.core.Jdbi.withHandle(Jdbi.java:341)
at test.TestSql.testArrayArg_onByteA(TestSql.java:84)
Basically i just want to get parent and children aggregated into arrays for each names and bytea fields in a single query. This works in psql, but i was not successful in getting the bytea[] value from the ResultSet.
The models:
-- for tests
CREATE TABLE parent (
id int GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
name VARCHAR(255) NOT NULL
);
CREATE TABLE child (
id int GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
parent_id int NOT NULL REFERENCES parent(id),
name VARCHAR(512) NOT NULL,
raw BYTEA NOT NULL
);
And the query:
private static final String FIND_PARENT =
"SELECT r.id AS id, r.name, f.children_names, f.children_bytesarr "
+ "FROM parent r "
+ " LEFT JOIN ("
+ " SELECT f.parent_id AS id, "
+ " ARRAY_AGG(f.name) as children_names, ARRAY_AGG(f.raw) as children_bytesarr "
+ " FROM child f "
+ " GROUP BY f.parent_id "
+ " HAVING f.parent_id = :parent_id"
+ " ) f USING (id) "
+ "WHERE r.id = :parent_id";
And here's the related code with resultSet (rs) which triggers the error, i leave the complete code below:
I'm submitting a ... (I am not sure whether this is currently supported or not, but i'll put it as a feature request for now)
Describe the issue
A clear and concise description of what the issue is.
Driver Version? --> 42.2.12
Java Version? --> openjdk version "11.0.7" 2020-04-14
OS Version? --> Debian 10.4
PostgreSQL Version? --> PostgreSQL 11.7 (Debian 11.7-0+deb10u1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit
To Reproduce
Steps to reproduce the behaviour: --> Run TestSql.java (JUnit)
Expected behaviour
(byte[][]) rs.getArray("children_bytesarr").getArray()
should work, just like(String[]) rs.getArray("children_names").getArray()
, but it throws error instead.The complete ddl, source code is provided below.
Logs
The error:
Basically i just want to get parent and children aggregated into arrays for each names and bytea fields in a single query. This works in psql, but i was not successful in getting the bytea[] value from the ResultSet.
The models:
And the query:
And here's the related code with resultSet (rs) which triggers the error, i leave the complete code below:
And here's the complete JUnit TestSql.java:
The test will pass if
.withChildrenBytesArr((byte[][]) rs.getArray("children_bytesarr").getArray())
is commented.Please share your thoughts.
The text was updated successfully, but these errors were encountered: