I'm building RESTful service on java using JERSEY and need to implement relationships between entities storing just identifier on another entity not whole. Is there any way to implements it in the hibernate?
I'm using something like this but it is not working.
@Entity
@javax.persistence.Table(name = "manager_user")
public class ManagerUser extends User {
@ManyToOne(targetEntity = ShopAdminUser.class)
private Integer shopAdminUserId;
//...
}
@Entity
@javax.persistence.Table(name = "shop_admin_user")
public class ShopAdminUser extends User {
@Lob
private String contactData;
public String getContactData() {
return contactData;
}
public void setContactData(String contactData) {
this.contactData = contactData;
}
}
@Entity
@Inheritance(strategy= InheritanceType.TABLE_PER_CLASS)
public abstract class User {
@Id
@GeneratedValue(strategy = GenerationType.TABLE)
private Integer id;
//...
}
It will be very comfortable for me to implement this.