Caused by: org.postgresql.util.PSQLException: ERROR: column "columnName" is of type text[] but expression is of type character varying
Hint: You will need to rewrite or cast the expression.
Position: 433
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2713)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2401)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:368)
at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:498)
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:415)
at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:190)
at org.postgresql.jdbc.PgPreparedStatement.executeUpdate(PgPreparedStatement.java:152)
at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:275)
... 59 more
DB column :
@Convert(converter = StringArrayConverter.class)
@Column(name = "columnName", columnDefinition = "text[]")
private String[] gvcBrands = new String[0];
Converter Class:
package com.coral.epos2.customers.model;
import jakarta.persistence.AttributeConverter;
import jakarta.persistence.Converter;
@Converter(autoApply = true)
public class StringArrayConverter implements AttributeConverter<String[], String> {
@Override
public String convertToDatabaseColumn(String[] attribute) {
}
@Override
public String[] convertToEntityAttribute(String dbData) {
}
}
I am getting above error when we want to insert the data into db. Please help me to write the proper converter class.
Remove StringArrayConverter
class. You don't need it.