root | ff0769a | 2025-05-18 17:24:41 +0000 | [diff] [blame^] | 1 | package entity; |
| 2 | |
| 3 | import java.util.Date; |
| 4 | import javax.persistence.*; |
| 5 | |
| 6 | @Entity |
| 7 | @Table(name = "UserVotes") |
| 8 | public class UserVotes { |
| 9 | |
| 10 | @EmbeddedId |
| 11 | private UserVotesId id; |
| 12 | |
| 13 | @ManyToOne(optional = false) |
| 14 | @JoinColumn(name = "user_id", referencedColumnName = "user_id", |
| 15 | foreignKey = @ForeignKey(name = "fk_user_votes_user")) |
| 16 | private User user; |
| 17 | |
| 18 | @ManyToOne(optional = false) |
| 19 | @JoinColumn(name = "beg_id", referencedColumnName = "beg_id", |
| 20 | foreignKey = @ForeignKey(name = "fk_user_votes_beg")) |
| 21 | private BegInfo begInfo; |
| 22 | |
| 23 | @ManyToOne(optional = false) |
| 24 | @JoinColumn(name = "seed_id", referencedColumnName = "seed_id", |
| 25 | foreignKey = @ForeignKey(name = "fk_user_votes_seed")) |
| 26 | private Seed seed; |
| 27 | |
| 28 | @Column(name = "created_at", nullable = false) |
| 29 | @Temporal(TemporalType.TIMESTAMP) |
| 30 | private Date createdAt; |
| 31 | |
| 32 | public UserVotes() {} |
| 33 | |
| 34 | // getter and setter for the composite key and other fields |
| 35 | public UserVotesId getId() { |
| 36 | return id; |
| 37 | } |
| 38 | |
| 39 | public void setId(UserVotesId id) { |
| 40 | this.id = id; |
| 41 | } |
| 42 | |
| 43 | // getters and setters for user, begInfo, seed, createdAt |
| 44 | } |