Here's the case:
1) Execute "insert" via non-batch multiple times. This causes pgjdbc to server-prepare the insert and use binary transfer for the generated keys.
Note: so far so good, it is perfectly fine.
2) Execute the same SQL via batch API. Here things break. Batch-insert wants generated keys in text format (there's QUERY_NO_BINARY_TRANSFER flag exactly for that case), and it does ask backend to send the data in text format. However, query metadata at pgjdbc side specify that "output columns are in binary format", thus generated keys resultset tries to access columns as binary and fails.
So possible workarounds are:
WA1) Add special marker (that is a comment) to batch SQL. That will make sure batch-insert uses its own statement.
WA2) mark INT8 as text-only. It is something like binaryTransferDisable=INT8 connection property
Vladimir