Answer the question
In order to leave comments, you need to log in
How to make mapping for classes in Spring?
There is a User class
@Entity
@Table(name = "users")
public class User {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer userId;
@OneToMany(mappedBy = "creator")
Set<Proposal> creatorsProposal;
@OneToMany(mappedBy = "performer")
Set<Proposal> performersProposal;
}
@Entity
@Table(name = "proposals")
public class Proposal {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer id;
@ManyToOne
@JoinColumn(name = "userId")
@NotNull
private User creator;
@ManyToOne
@JoinColumn(name = "userId")
private User performer;
Repeated column in mapping for entity: Proposal column: user_id (should be mapped with insert="false" update="false")
Answer the question
In order to leave comments, you need to log in
@JoinColumn must contain different columns, for example
@JoinColumn(name = "creatorUserId") and @JoinColumn(name = "performerUserId")
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question