Code: Select all
@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
public class Person {
private String name;
< /code>
und untergeordnete Klassen: < /p>
@Entity
public class Hunter {
private String forest;
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinColumn(name = "hunter_id", referencedColumnName = "id")
private Set dogs;
< /code>
@Entity
public class Policeman {
private String city;
@OneToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "dog_id")
private Dog dog;
< /code>
It generates table structure like this:
[b]person[/b]
id, name, forest, city, dog_id, person_type
< /code>
[b]dog[/b]:
id, breed, hunter_id
< /code>
So essentially because the Policeman