我想将类Channel中的字段firstUser和secondUser映射到类User中的字段Id,但我不知道该怎么做。请帮我!这是我的代码.....
@Entity
@Table(name = "tb_user")
public class User implements UserDetails {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
@Column(name = "firstname")
@NotNull(message = "Firstname can not be null")
private String firstName;
@Column(name = "lastname")
@NotNull(message = "Lastname can not be null")
private String lastName;
.....
}
@Entity
@Table(name = "tb_message_channel")
public class Channel {
private int firstUser;
private int secondUser;
@Column(name = "channel_uuid")
private String channelId;
@Column(name = "created_date")
@CreationTimestamp
private Timestamp createdDate;
......
}