Advertisement
Guest User

Untitled

a guest
Feb 19th, 2025
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.03 KB | None | 0 0
  1. @Entity
  2. @Table(name = "users_rooms")
  3. public class UserRoom {
  4.  
  5.     @EmbeddedId
  6.     private UserRoomId id;
  7.  
  8.     @NotNull
  9.     @ManyToOne(fetch = FetchType.LAZY)
  10.     @JoinColumn(name = "user_id")
  11.     private User user;
  12.     public User getUser() { return user; }
  13.     public void setUser(User user) { this.user = user; }
  14.  
  15.     @NotNull
  16.     @ManyToOne(fetch = FetchType.LAZY)
  17.     @JoinColumn(name = "room_id")
  18.     private Room room;
  19.     public Room getRoom() { return room; }
  20.     public void setRoom(Room room) { this.room = room; }
  21.  
  22.     @Column(name = "notifications_muted")
  23.     private boolean notificationsMuted;
  24.     public boolean getNotificationsMuted() { return notificationsMuted; }
  25.     public void setNotificationsMuted(boolean notificationsMuted) { this.notificationsMuted = notificationsMuted; }
  26.  
  27.     public UserRoom() {}
  28.     public UserRoom(User user, Room room){
  29.         this.user = user; this.room = room;
  30.     }
  31. }
  32.  
  33. @Embeddable
  34. class UserRoomId implements Serializable{
  35.     private Long user;
  36.     private Long room;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement