I am encountering an issue with Hibernate 6's NativeQuery when trying to pass a parameter of type array to a database function. The problem arises when the parameter is passed as a single value or as a list of values. The issue occurs in the following method:
The function declaration in the database is as follows:
Details:
- When a single value is passed in the parameter (list size equals 1), the following error occurs:
- When two or more values are passed in the parameter (list size greater than 1), the following error occurs:
Attempted Solutions: I have tried converting the list to an array using idOwners.toArray() when setting the parameter, but the same issue persists. I also attempted to pass the parameter as a direct string in the SQL query using the syntax "ARRAY[1, 2]". Although this approach seems to work, it is not a recommended solution as the syntax for array parameters may vary across different database systems, posing compatibility issues. Expected Behavior: The Hibernate NativeQuery should correctly pass the parameter as bigint[] to match the function declaration in the database, regardless of whether it is a single value or a list of values. |