Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PostgreSQL and Hibernate java.io.IOException: Tried to send an out-of-range integer as a 2-byte value

I have hibernate query:

getSession()                     
        .createQuery("from Entity where id in :ids") 
        .setParameterList("ids", ids)
        .list();

where ids is Collection ids, that can contain a lot of ids. Currently I got exception when collection is very large: java.io.IOException: Tried to send an out-of-range integer as a 2-byte value I heard that postgre has some problem with it. But I can't find the solution how to rewrite it on hql.

like image 817
Роман Бондаренко Avatar asked Mar 14 '18 09:03

Роман Бондаренко


1 Answers

The exception occurs because of PostgreSQL's limit of 32767 bind variables per statement. As a possible workaround try to split your large query into smaller ones.

like image 103
Andrey Dolgikh Avatar answered Oct 19 '22 02:10

Andrey Dolgikh