Make UserTypes usable in Query.setParameter

Description

After long searching for a way to pass arrays as parameters, the closest thing to a solution people recommended was implementing a UserType for them and even had examples of such. They were supposed to be loaded through the xml configuration, so I after I did that I discovered that the data is never entered into the map that is looked-up for the types when calling setParameter().
Wrote 40 lines of code in Configuration.buildSessionFactory and I made it work. Tested it in the company project and got the desired results from the PostgreSQL query "SELECT * FROM my_table WHERE id = ANY(:boo)" . It doesn't work with "id IN :boo" or with positional parameters like "id = ANY", but that can be smoothed-out later if you agree with the idea at large.

Environment

None

Activity

Show:
Vlad Mihalcea
November 15, 2017, 4:20 PM

This is no longer relevant since MetadataBuilder.applyBasicType(UserType type, String... keys) allows you to register a UserType during bootstrap.

Assignee

Unassigned

Reporter

Йордан Гигов

Fix versions

None

Labels

backPortable

None

Suitable for new contributors

None

Requires Release Note

Affirmative

Pull Request

None

backportDecision

None

Components

Priority

Minor
Configure