hibernate-types-52 (sometimes) insert double quotes around Strings at text[] Postgres columns

Viewed 192

Using this code sample:

import com.vladmihalcea.hibernate.type.array.ListArrayType;

@Getter
@Setter
@TypeDef(
    name = "list-array",
    typeClass = ListArrayType.class
)
@MappedSuperclass
public class MySample extends Audit {

    @NotAudited
    @Type(type = "list-array")
    @Column(
        name = "list_one",
        columnDefinition = "text[]"
    )
    private List<String> listOne;

    @NotAudited
    @Type(type = "list-array")
    @Column(
        name = "list_two",
        columnDefinition = "text[]"
    )
    private List<String> listTwo;

    @NotAudited
    @Type(type = "list-array")
    @Column(
        name = "list_three",
        columnDefinition = "text[]"
    )
    private List<String> listThree;

Along with this dependency:

<dependency>
    <groupId>com.vladmihalcea</groupId>
    <artifactId>hibernate-types-52</artifactId>
    <version>2.10.2</version>
</dependency>

We are able to convert a java.util.List of strings to our desired format {string1,string2,...,stringN}. If we query the Postgres database in local environments these three columns appear as expected - however in some other environments we get {"string1","string2",...,"stringN"} (with quotes). We've been making an effort to understand why the different behaviour for the exact same code and test.

Although the code is exactly the same, in local environments we have a Postgres 10.17 installation in our Macbooks, whereas in our AWS environments RDS is used with Postgres 10.16, however I am not sure if this is relevant for this issue.

Does anyone have any explanation(s) on what may cause this? Thank you for your help.


Edit: We realised that this happens only for strings containing white spaces, e.g. oneword, two words, result in{oneword,"two words"}

0 Answers
Related