'StackOverflowError - mappedBy
I have an entity account that I would like to link with another entity account.
When testing with postman I get a StackOverflowError because the list of friends is reloaded to infinity
What can I do to solve my problem?
public class Account {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@ManyToMany
@JoinTable(name = "ludo",
joinColumns = @JoinColumn(name = "id_account"),
inverseJoinColumns = @JoinColumn(name = "id_boardGame"))
private List<Boardgame> boardgameList;
@OneToMany(mappedBy = "friend")
List<Friends> FriendsList;
}
@Data
@AllArgsConstructor
@NoArgsConstructor
@Entity
public class Friends {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int id_friends;
@JsonIgnore
@OneToOne
@JoinColumn(name="FK_account", referencedColumnName="account_id")
private Account account;
@OneToOne( fetch = FetchType.LAZY)
@JoinColumn(name="FK_friend",nullable = false, referencedColumnName="account_id")
private Account friend;
@Column(updatable = false)
@CreationTimestamp
private LocalDateTime createdAt;
}
Solution 1:[1]
The port is already in use. To fix it, you can :
- Change the port that you are using in the
server.propertiesfile - Stop the other server which is running on
25565port. For example, if you are on linux and you don't know which process is using it, usefuser -k 25565/tcp, which will kill the current process and that port.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Elikill58 |
