[hibernate-dev] Mapping different objects with a single table
Teresa Batista Neto
teresa.batista.neto at gmail.com
Thu Apr 25 04:32:57 EDT 2013
Dear all,
We have a java class that contains a list of names of type A, a list of
names of type B, and a preferred name. We would like to map this list of
names and the preferred name in a single table called names that contains
id, name and type. I already had a look in hibernate documentation but I
didn't find how to do that. Can someone help me with this issue? I'm stuck
in this problem, any help will be great.
e.g.
public class Entry
{
private String preferredName;
private List<String> synsNames = new ArrayList<String>();
private List<String> locusNames = new ArrayList<String>();
private List<String> orfNames = new ArrayList<String>();
...
}
CREATE TABLE names (
name_id number NOT NULL,
entry_id number NOT NULL,
name varchar(200) NOT NULL,
type_id number NOT NULL,
CONSTRAINT pk_name PRIMARY KEY (name_id),
CONSTRAINT uq_name UNIQUE (entry_id, name)
);
plus foreign key between entry and names...
optional table type or instead of type_id just type..
Thanks in advance,
Teresa
More information about the hibernate-dev
mailing list