I'm new to Spring and wondering how to go about achieving something.
I want to include a Collection of mapped entities with doing a GET on an owning entity.
For example, say I have an entity that looks like:
@Entity
@Table(name="USERS")
public class ApplicationUserEntity {
private Integer id;
private String name;
private String email;
private String eid;
private Collection<TaskEntity> tasksById;
and includes a getter for Tasks
@OneToMany(targetEntity = TaskEntity.class, mappedBy = "userByUserId")
public Collection<TaskEntity> getTasksById() {
return tasksById;
}
When I GET the data for a user entity using the direct path (ie something like /users/1 because i changed the path in my repository) or with a search endpoint (ie /users/search/findById?id=1), it would return to me the properties from the User entity that are not mapped to other entities, but also include a link so I know how to fetch the tasks that this user has.
Aside from making a separate API call from the front end, how could I get the tasks to come back with the rest of the data? My reason for avoiding a projection is that I'm unable to do sorting with the ?sort query param if i also use a projection.