I am trying to map an array of custom type returned by a postgres procedure to the java
I have a custom type in postgres as
CREATE TYPE public.customtype_sample AS(
sampleid bigint,
samplename character varying,
samplevalue character varying
)
The procedure returns an array of customtype_sample
as column of type customtype_sample[]
in postgres
I went through various link: How to map User Data Type (Composite Type) with Hibernate
Array with UserType in Hibernate and PostgreSQL --> MappingException
and may more wrote a class that implements array of sampletype but i end up getting this exception
"could not execute query"
caused by : org.postgresql.util.PSQLException: Method org.postgresql.jdbc4.Jdbc4Array.getArrayImpl(long,int,Map) is not yet implemented.
The error occurs in the nullSafeGet method of the userType
@Override
public Object nullSafeGet(ResultSet rs, String[] names,
SessionImplementor session, Object owner)
throws HibernateException, SQLException {
SampleType[] javaArray = null;
Array array = (Array) rs.getArray(names[0]);
if (!rs.wasNull()) {
javaArray = (SampleType[]) array.getArray();//error occurs here
}
return toReferenceType(javaArray);
}
seems when i am trying to get the array of custom type there might be some problem not able to understand how to write usertype class for an array of customtype. Any help will be appreciated.
Had the same error, and I fixed it by upgrading PostgreSQL JDBC from 9.2-1002-jdbc4 to 9.4-1201-jdbc41
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With