0

I use prosgres sql and the table is like this.

CREATE TABLE invoice ( id INTEGER NOT NULL PRIMARY KEY, item_ids INTEGER[] NOT NULL, seller VARCHAR(10) NOT NULL );

Here I want to map the 'item_ids' array to the Integer array (Integer[]) in hbm.xml. This Integer array does not have any other references.Only an array Any sample code please.

Débora
  • 5,816
  • 28
  • 99
  • 171

2 Answers2

1

You can't map Integer array in Hibernate. Use List<Integer> using <list></list> tags.

Masudul
  • 21,823
  • 5
  • 43
  • 58
0

I think you need to modify your database structure to be as follows:

CREATE TABLE invoice ( id INTEGER NOT NULL PRIMARY KEY, seller VARCHAR(10) NOT NULL);

CREATE TABLE invoice_items ( invoice_id INTEGER NOT NULL, item_id INTEGER NOT NULL);
Ahmad Abdelghany
  • 11,983
  • 5
  • 41
  • 36