The following code behaves differently between Hibernate 6.1 and 6.4 on postgresql:
var rows =
session
.createNativeQuery("SELECT CAST('[1,2,3]' as jsonb) as data, 2 as id", Object[].class)
.addScalar("data")
.addScalar("id", StandardBasicTypes.INTEGER)
.list();
rows.forEach(row -> System.out.println(row[0].getClass() + " -> " + row[0]));
Output with 6.1:
class java.util.ArrayList -> [1, 2, 3]
Output with 6.4:
class java.lang.String -> [1, 2, 3]
In 6.1, it converts the jsonb column into an ArrayList; but on 6.4 it just reads it as a String. I tried passing in a bunch of different StandardBasicTypes and none of them made 6.4 behave like 6.1. So, how can I do this in 6.4?
Here is code to reproduce this: https://github.com/chadselph/hibernate-json-native-query
using UserType!
*** JsonbType implements UserType ***