One way is to use projections, for example, for example:
@Projection(name = "edit" , types = Employee.class) public interface EditEmployeeProjection { String getFirstName(); String getLastName(); Set<Project> getProjects(); }
The list of projects will be embedded in the result for http: // localhost: 8080 / api / employee / 1? Projection = edit
Predictions will be used automatically if you add excerptProjection to your repository, as described here: How to set up a complete tree structure using Spring Data REST and HATEOAS?
See here: https://shinesolutions.com/2015/04/15/spring-data-rest-and-projections/
EDITED
In this case, the projection will look like this:
@Projection(name = "edit" , types = UserCompetency.class) public interface UserCompetencyProjection { User getUser(); Competency getCompetency(); }
With http: // localhost: 8080 / userCompetencies? Projection = edit, you would see the desired result.

EDITED 2 Code I used:
Competency.class
@Entity @Table(name = "competency", schema = "public") @JsonIdentityInfo( generator = ObjectIdGenerators.IntSequenceGenerator.class, property = "competencyId") public class Competency implements java.io.Serializable { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "competency_id", unique = true, nullable = false) private Long competencyId; @OneToMany(fetch = FetchType.LAZY, mappedBy = "competency") private List<UserCompetency> userCompetencies = new ArrayList<>();
UserCompetency.class
@Entity @Table(name = "user_competency", schema = "public") @JsonIdentityInfo( generator = ObjectIdGenerators.IntSequenceGenerator.class, property = "id") public class UserCompetency implements java.io.Serializable { @EmbeddedId @AttributeOverrides({ @AttributeOverride(name = "competencyId", column = @Column(name = "competency_id", nullable = false)), @AttributeOverride(name = "userId", column = @Column(name = "user_id", nullable = false)) }) private UserCompetencyId id; @ManyToOne(fetch = FetchType.EAGER) @JoinColumn(name = "user_id", nullable = false, insertable = false, updatable = false) private User user; @ManyToOne(fetch = FetchType.EAGER,cascade = CascadeType.ALL) @JoinColumn(name = "competency_id", nullable = false, insertable = false, updatable = false) private Competency competency;
UserCompetencyId.class
@Embeddable public class UserCompetencyId implements java.io.Serializable { @Column(name = "competency_id", nullable = false) private Long competencyId; @Column(name = "user_id", nullable = false) private Long userId;
UserCompetencyRepository.class
@RepositoryRestResource(excerptProjection = UserCompetencyProjection.class) public interface UserCompetencyRepository extends JpaRepository<UserCompetency, UserCompetencyId> { After Implementing This ,In my case its not working to show desired jason [![enter image description here][2]][2]