Hibernate mapping allows you to define two objects coming from the same table
For example, I can easily have two POJOS, say, Person and Name
Code:
Person
------
dateOfBirth: Date
name: Name
...
------
and
Code:
Name
------
firstname: String
lastname: String
------
mapped to one table
Code:
PERSON
------
PERSON_ID INTEGER PRIMARY KEY
DATE_OF_BIRTH DATETIME
FIRST_NAME VARCHAR
LAST_NAME VARCHAR
-----
The question is, if I have a complex (e.g. long, but flat) POJO, can I map it across two tables.
For example, one POJO called Person
Code:
Person
------
dateOfBirth
name: Name
firstname: String
lastname: String
...
------
mapped to two tables PERSON and NAME with the same primary key
Code:
PERSON
------
PERSON_ID INTEGER PRIMARY KEY
DATE_OF_BIRTH DATETIME
-----
and
Code:
NAME
------
PERSON_ID INTEGER PRIMARY KEY
FIRST_NAME VARCHAR
LAST_NAME VARCHAR
-----
Hibernate version: Any