I am using the latest hibernate version (6.5) and hypersistence utils in this version is not supporting custom array types as it’s natively supported by hibernate > 6.4.
I’ve tested and this works natively for float[] arrays, so e.g. this works
@Entity
public class MyEntity {
float[] myArray
}
but if I do the same for a 2d array:
float[][] myArray
I get this error:
Caused by: java.lang.ClassCastException:
class org.hibernate.type.internal.BasicTypeImpl cannot be cast to class org.hibernate.type.BasicPluralType (org.hibernate.type.internal.BasicTypeImpl and org.hibernate.type.BasicPluralType are in unnamed module of loader ‘app’)
So it seems mapping the column as json and using columnDefinition = "jsonb" seems to be only solution. Is there another way to map multidimensional arrays natively supported by hibernate 6.5?
2
Answers
Consider using a custom type definition using the built-in
FloatPrimitiveArrayJavaType
Hypersistence-Utils and PostgreSQL support the use of multi-dimensional arrays.
Tested using