1

I have the following entities

class ItemList {
  long id;
  List<Item> items;
}

and

class Item {
  long id;
  String name;
}

I would like to represent them with the following tables

table ITEM_LIST (
  item_list_id number primary key
);

table ITEM (
  item_id number primary key,
  name varchar(255) not null
);

for the primary entities, and a join table for the relationship;

table ITEM_LIST_REL (
  item_list_id number,
  item_id number,
  seq_no number
);

where seq_no gives the sequence number of the item in the item list - in effect, the index of the item in the List object.

How can I map that using Hibernate or java.persistence annotations?

Vihung
  • 12,947
  • 16
  • 64
  • 90

0 Answers0