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.

3
  • Are you using any IDE? Commented Oct 28, 2013 at 13:03
  • Eclipse, Kepler is used. but I need to do it manually. :) Commented Oct 28, 2013 at 13:04
  • well you can go this way: stackoverflow.com/questions/14219498/… , or just use a List... Commented Oct 28, 2013 at 13:04

2 Answers 2

1

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

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

7 Comments

thanks for reply. then can you let me know how about the column type should be ? What is the column type should be ?
You need mapping OneToMany or use @EllementCollection
I can't use annotations all hibernates are written as XML
or then can I use int[] (primitive type) ? if can any sample please ?
|
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);

Comments

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.