简体   繁体   中英

How to map Integer array in Hibernate in hbm.xml

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.

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

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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM