0
   @Entity
    @Table(name = "profiles")
    data class Profile(
    @Id
        @GeneratedValue(generator = "UUID")
        @GenericGenerator(
                name = "UUID",
                strategy = "org.hibernate.id.UUIDGenerator"
        )
        @Column(name = "id", updatable = false, nullable = false)
        val id: UUID,

    @Column(name = "first_name")
        var firstName: String? = null,

        @Column(name = "last_name")
        var lastName: String? = null,

    @Column(name = "phones")
        var phones: String? = null
}

In Postgres has table profiles and has column 'phones' => character varying[] (Array) How can I set type to update and insert datas?

I have errors if I set List<> or Array<> ArrayList<> :

org.postgresql.util.PSQLException: ERROR: column "phones" is of type character varying[] but expression is of type character varying
  Hint: You will need to rewrite or cast the expression.
1

1 Answer 1

0

Are you trying to get a date inside phones column? As I see it you are trying to add phones, and String is the correct type for it, I would add a logic inside postger that adds a new date upon update.

Sign up to request clarification or add additional context in comments.

2 Comments

I have many columns on db character varying[] (Array String), how can I use on Kotlin there column for array?
If you need a dynamic sized array, try to use a List and a foreach loop, if you need a fixed number you can use: var myArr = arrayOf("num1", num2", "num3")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.