Display fields in Play
I got three tables User Topic and Post
I linked those with @ManytoOne and @OnetoMany like :
User.java ---
@Id
public Long id;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "user")
public List<Post> post = new ArrayList<Post>();
@OneToMany(cascade = CascadeType.ALL, mappedBy = "user")
public List<Topic> topic = new ArrayList<Topic>();
Topic.java ----
@Id
public Long id;
@ManyToOne
@JoinColumn(name = "user_id")
public Users user;
@ManyToOne
@JoinColumn(name = "topic_id")
public Topic topic;
Post.java ---
@Id
public Long id;
@ManyToOne
@JoinColumn(name = "user_id")
public Users user;
@ManyToOne
@JoinColumn(name = "topic_id")
public Topic topic;
public String title;
public String article;
@CreatedTimestamp
public Date created;
To display Topic i use :
@(users:List[Users])
@for(user <- users){
@for(topic <- user.topic){
<a href="@routes.Forum.showtopic(topic.id)">@topic.title</a>
}
}
this Topic has full information of User, But i can do this again with
Post, Post has information of Topic, not User. So how can i solved it.
Thanks for help
No comments:
Post a Comment