Spaces:
Sleeping
Sleeping
File size: 957 Bytes
bb5169d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
package com.krishna.model;
import jakarta.persistence.*;
import java.util.*;
@Entity
@Table(name = "likes", uniqueConstraints = {
@UniqueConstraint(columnNames = {"user_id", "post_id"})
})
public class LikeModel {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@ManyToOne
private UserModel user;
@ManyToOne
private PostModel post;
public LikeModel() {}
public LikeModel(UserModel user, PostModel post) {
this.user = user;
this.post = post;
}
// Getters and setters
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public PostModel getPost() {
return post;
}
public void setPost(PostModel post) {
this.post = post;
}
public UserModel getUser() {
return user;
}
public void setUser(UserModel user) {
this.user = user;
}
}
|