Skip to content

Commit

Permalink
Add user field in the OnlineStatusEntity (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
oleksii-yavtushenko authored Apr 19, 2021
1 parent 8f339dd commit 59d4d56
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
@Table(name = "online_status")
@Data
@Builder
@ToString
@EqualsAndHashCode
@AllArgsConstructor
@NoArgsConstructor
Expand All @@ -19,7 +18,22 @@ public class OnlineStatusEntity implements Serializable {
@Id
private Long id;

@EqualsAndHashCode.Exclude
@OneToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "user_id")
private UserEntity user;

private OffsetDateTime lastOnlineTime;

private Boolean isOnline;

@Override
public String toString() {
return "OnlineStatusEntity{" +
"id=" + id +
", user.id=" + user.getId() +
", lastOnlineTime=" + lastOnlineTime +
", isOnline=" + isOnline +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ public class UserEntity implements Serializable {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@OneToOne
@PrimaryKeyJoinColumn(referencedColumnName = "user_id")
@OneToOne(mappedBy = "user")
private OnlineStatusEntity onlineStatus;

private String login;
Expand Down

0 comments on commit 59d4d56

Please sign in to comment.