In my application I have three entities, BaseNotification as a parent and SmsNotification and EmailNotification as child entities which extend BaseNotification.
I am using hibernate single table inheritance strategy so all attributes fit into one table.
Lets say I have some common attributes on BaseNotification entity, and child entities have one specific attribute each (SmsNotification has mobileNumber and EmailNotification has email attribute).
public abstract class BaseNotification implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "name")
private String name;
@Column(name = "description")
private String description;
...
}
public abstract class EmailNotification extends BaseNotification implements Serializable {
private static final long serialVersionUID = 1L;
@Column(name = "email")
private String email;
...
}
public abstract class SmsNotification extends BaseNotification implements Serializable {
private static final long serialVersionUID = 1L;
@Column(name = "mobileNumber")
private String mobileNumber;
...
}
Is there a way of fetching all notifications with all attributes while sorting on child attributes (for example by email) in one go with spring rest?