Skip to content

Instantly share code, notes, and snippets.

@saqibmehmoodgit
Last active June 26, 2021 20:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saqibmehmoodgit/173bfe18c3329a3ea76eac4401fac3d7 to your computer and use it in GitHub Desktop.
Save saqibmehmoodgit/173bfe18c3329a3ea76eac4401fac3d7 to your computer and use it in GitHub Desktop.
User(table) Post(table) Comments(table)
userid name postid title commntsid commnets userid postid
@Entity @Entity @Entity
@Table(name = "user") @Table(name = "post") @Table(name = "comments")
public class User public class Post public class Comments
{ { {
@OneToMany(mappedBy = "user")
List<Post> post=new ArrayList<>(); @ManyToOne(fetch = FetchType.LAZY) @ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "uid") @JoinColumn(name = "uid")
private User user; private User user;
@OneToMany(mappedBy = "user") @OneToMany(mappedBy = "post") @ManyToOne(fetch = FetchType.LAZY)
List<Comments> commnts=new ArrayList<>(); List<Comments> commnts=new ArrayList<>(); @JoinColumn(name = "postid")
private Post post
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment