I'm trying to help to colleague. We tried to do bidirectional @OneToMany and @ManyToOne relationship between entities. But when we return One of the entities through PostMan we get infinite objects mapping recursion. I guess Entities joined wrong. We thought that it is ok. Maybe you know how to relate it correctly?
it's car rental information system. Each User can rent vehicles. Each Booking involves 1 vehicle. A user can make many bookings. But each Booking has one User.
Entities are these:
@Entity
@Data
@Table
public class AbstractUser {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer id;
private String password;
private String firstName;
private String lastName;
private String emailAddress;
private String userType;
// Unidirectional
@OneToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "address_Id")
private Address address;
@OneToMany(mappedBy = "user", cascade = CascadeType.ALL)
private List<Booking> bookings;
@OneToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "vehicle_Id")
private Vehicle vehicle;
//...