I actually think single table would fit your needs best, especially if you have many to many relationships.
On my website (and in my book) I map the following inheritance hierarchy using Hibernate:
It's actually pretty simple:
http://jpa.ezhibernate.com/Javacode/learn.jsp?tutorial=16mappinginheritancewithjpa
Code:
package com.examscam.mappings;
import javax.persistence.*;
@Entity
public class Ancestor {
private Long id;
private String nationality;
@Id
@GeneratedValue
public Long getId() {return id;}
public void setId(Long id) {this.id = id;}
public String getNationality() {return nationality;}
public void setNationality(String nationality) {
this.nationality = nationality;
}
}
Code:
package com.examscam.mappings;
import javax.persistence.*;
@Entity
public class Parentextends Ancestor{
private String lastName;
public String getLastName() {return lastName;}
public void setLastName(String lastName) {
this.lastName = lastName;
}
}
Code:
package com.examscam.mappings;
import javax.persistence.*;
@Entity
public class Child extends Parent {
private String firstName;
public String getFirstName() {return firstName;}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
}
Code:
public static void main(String args[]) {
Ancestor a = new Ancestor();
a.setNationality("Korean");
Parent p = new Parent();
p.setNationality("Jewish"); p.setLastName("Steinberg");
Child c = new Child();
c.setNationality("Irish");
c.setLastName("McKenzie");
c.setFirstName("Cameron");
Session session = HibernateUtil.beginTransaction();
session.save(a); session.save(p); session.save(c);
HibernateUtil.commitTransaction();
}
When you're done, you get a very simple and manageable talbe with your data in it. Mappings and associations can be added, and they fit into the single talbe nicely:
http://jpa.ezhibernate.com/Javacode/learn.jsp?tutorial=16mappinginheritancewithjpa