JPA: foreign key annotation

As Forum has many topics, and a topic belongs to one and only Forum, you probably want to go with a Forum type attribute annotated with @ManyToOne:

@ManyToOne
@JoinColumn(name = "forumId")
private Forum forum;

See more:

ManyToOne and JPA mapping

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)