Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support of PostgreSQL types in PostgreSQL array #311

Open
arturmkr opened this issue Apr 11, 2021 · 4 comments
Open

Add support of PostgreSQL types in PostgreSQL array #311

arturmkr opened this issue Apr 11, 2021 · 4 comments

Comments

@arturmkr
Copy link

For example, there is a following DTO in PostgreSQL:

create table email
(
    account_id varchar(100),
    id varchar(100),
    recipients recipient[],
    subject varchar(100),
    content varchar(100)
);
create type recipient as
(
    email text,
    name  text
);

There is an option to use PostgreSQL array:
https://vladmihalcea.com/postgresql-array-java-list/

But there is no option to use in PostgreSQL array custom types.

With Regards

@vladmihalcea
Copy link
Owner

I've never used custom PostgreSQL Types. If you figure out how to do it, send me a Pull Request, and I'll review it when I have some time.

@arturmkr
Copy link
Author

I am not so good at Hibernate to make PR to fix it.

But using plain SQL it works in a following way:
INSERT INTO public.email (account_id, id, recipients, subject, content) VALUES ('qwerty', 'aa12345', '{(frank@example.com,"frank"),(john@example.com,"john")}', 'mysubject', 'mycontent');

@vladmihalcea
Copy link
Owner

That's a good start. Now, you need to check out how to fo that with a JDBC PreparedStatement and send that with a bind parameter value.

@jwgmeligmeyling
Copy link
Contributor

jwgmeligmeyling commented Jun 22, 2021

This would be much easier to implement if pgjdbc had support for structs. Unfortunately they abandoned the idea for probably the same reasons this should not be implemented as part of hibernate-types: pgjdbc/pgjdbc#381.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants