2

I am using postgres database and spring with hibernate in my project.

I just want to get some datas from DB, where the table having array datatype column in itself.

While I am getting from that table I am getting the following error.

    ERROR org.hibernate.util.JDBCExceptionReporter  - ERROR: relation "reconcileprocess_bankstmtid" does not exist

Table structure as follows

    CREATE TABLE reconcile_process
    (
      id bigserial NOT NULL,
      comments character varying,
      fk_last_modified_by bigint NOT NULL,
      last_modified_date timestamp with time zone NOT NULL,
      fk_remittance_transaction_fkey character varying,
      fk_transaction_ref character varying,
      process_type character varying,
      reconcilled_date date,
      fk_bank_stmt_id bigint[]
    )

Entity class for that table

    @Entity
    @Table(name = "reconcile_process")
    public class ReconcileProcess implements Serializable {

        private static final long serialVersionUID = 1L;

        @Id
        @Column(name = "id")
        Long id;

        @Column(name = "comments")
        String comments;

        @Column(name = "fk_last_modified_by")
        Long lastModifiedBy;

        @Column(name = "last_modified_date")
        Date lastModifiedDate;

        @Column(name = "fk_transaction_ref")
        String transactionRef;

        @Column(name = "fk_remittance_transaction_fkey")
        String remitTransactionRef;

        @Column(name = "process_type")
        String processType;

        @Column(name = "reconcilled_date")
        Date reconcilledDate;

        @ElementCollection
        @Column(name = "fk_bank_stmt_id")
        List<Long> bankStmtId;
DevGo
  • 1,045
  • 1
  • 16
  • 42

1 Answers1

0

Hibernate does not support database arrays (java.sql.Array).

You get the error because Hibernate expects a separate table for List<Long> bankStmtId (because you didn't explicitly specify the table name, Hibernate assumes the default of <entity name>_<property name>, thus reconcileprocess_bankstmtid).

You can either switch to the supported approach with a separate table, or as explained here, you can try to write custom user type for database arrays.

Community
  • 1
  • 1
Dragan Bozanovic
  • 23,102
  • 5
  • 43
  • 110