Hibernate version:
3
Name and version of the database you are using:
postgres 8
I was hoping someone might be able to give me some insight on how to map the following situation:
Code:
create table human (
id serial primary key,
hair_color text
);
create table person (
id serial primary key,
human_id integer references human,
name text
);
-----------------
HUMAN
-----------------
id | hair_color
----+------------
1 | brown
2 | black
3 | blonde
4 | red
----------------------
PERSON
----------------------
id | human_id | name
----+----------+------
1 | 1 | mike
2 | 1 | dan
3 | 1 | fred
public class human {
Integer id;
String hair_color;
}
public class person extends human {
Integer id;
String name;
}
I looked into trying to map this using a table-per-subclass, but it seems this type of mapping is for a one-to-one mapping. I want a one-to-many mapping and it seems that it is possible from Table 10.1. Features of inheritance mappings from
http://www.hibernate.org/hib_docs/v3/reference/en/html/inheritance.htmlbut I could find any documentation on it. Could someone suggest how I might map these or point me to where I might find this in the docs?
The only way I could see how I might do this is via:
Code:
public class person {
Integer id;
String name;
human h;
}
thanks in advance,
Mike