Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Your classes should looks like this:<br> Human </p> <pre><code>import java.io.Serializable; import javax.persistence.Entity; import javax.persistence.EnumType; import javax.persistence.Enumerated; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.Inheritance; import javax.persistence.InheritanceType; @Entity @Inheritance(strategy = InheritanceType.JOINED) public class Human implements Serializable { private static final long serialVersionUID = 1L; public static enum Gender { Male, Female } @Id @GeneratedValue private Long id; @Enumerated(EnumType.STRING) private Gender gender; private String firstName; private String lastName; public Long getId() { return id; } public void setId(Long id) { this.id = id; } public Gender getGender() { return gender; } public void setGender(Gender gender) { this.gender = gender; } public String getFirstName() { return firstName; } public void setFirstName(String firstName) { this.firstName = firstName; } public String getLastName() { return lastName; } public void setLastName(String lastName) { this.lastName = lastName; } ..... } </code></pre> <p>User</p> <pre><code>import java.util.Date; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.PrimaryKeyJoinColumn; import javax.persistence.Temporal; import javax.persistence.TemporalType; @Entity @PrimaryKeyJoinColumn public class User extends Human { private static final long serialVersionUID = 1L; @Column @Temporal(TemporalType.DATE) private Date registrationDate; public Date getRegistrationDate() { return registrationDate; } public void setRegistrationDate(Date registrationDate) { this.registrationDate = registrationDate; } .... } </code></pre> <ul> <li>Human class should be annotated by @Entity annotation</li> <li>Model entity classes should implement Serializable interface</li> </ul> <p>See</p> <ol> <li><a href="http://blog.v-s-f.co.uk/2010/12/inheritance-type-with-hibernate/" rel="nofollow">Inheritance Type (With Hibernate)</a>.</li> <li><a href="http://www.java2s.com/Tutorial/Java/0355__JPA/InheritanceTypeJOINED.htm" rel="nofollow">Inheritance Type JOINED</a></li> </ol>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload