1 | package edu.ucsb.cs156.happiercows.entities; | |
2 | ||
3 | import lombok.AllArgsConstructor; | |
4 | import lombok.Data; | |
5 | import lombok.NoArgsConstructor; | |
6 | import lombok.AccessLevel; | |
7 | import lombok.Builder; | |
8 | ||
9 | import javax.persistence.CascadeType; | |
10 | import javax.persistence.Entity; | |
11 | import javax.persistence.FetchType; | |
12 | import javax.persistence.GeneratedValue; | |
13 | import javax.persistence.GenerationType; | |
14 | import javax.persistence.Id; | |
15 | import javax.persistence.JoinTable; | |
16 | import javax.persistence.ManyToMany; | |
17 | import javax.persistence.JoinColumn; | |
18 | ||
19 | import com.fasterxml.jackson.annotation.JsonManagedReference; | |
20 | ||
21 | import java.time.Instant; | |
22 | import java.util.List; | |
23 | ||
24 | @Data | |
25 | @AllArgsConstructor | |
26 | @NoArgsConstructor(access = AccessLevel.PROTECTED) | |
27 | @Builder | |
28 | @Entity(name = "users") | |
29 | public class User { | |
30 | @Id | |
31 | @GeneratedValue(strategy = GenerationType.IDENTITY) | |
32 | private long id; | |
33 | private String email; | |
34 | private String googleSub; | |
35 | private String pictureUrl; | |
36 | private String fullName; | |
37 | private String givenName; | |
38 | private String familyName; | |
39 | private boolean emailVerified; | |
40 | private String locale; | |
41 | private String hostedDomain; | |
42 | private boolean admin; | |
43 | ||
44 | @Builder.Default | |
45 | private Instant lastOnline = Instant.now(); | |
46 | ||
47 | @ManyToMany(fetch = FetchType.EAGER, cascade = {CascadeType.PERSIST,CascadeType.REMOVE}) | |
48 | @JoinTable(name = "user_commons", | |
49 | joinColumns = @JoinColumn(name = "user_id", referencedColumnName = "id"), | |
50 | inverseJoinColumns = @JoinColumn(name = "commons_id", referencedColumnName = "id")) | |
51 | private List<Commons> commons; | |
52 | ||
53 | @Override public String toString() { | |
54 |
1
1. toString : replaced return value with "" for edu/ucsb/cs156/happiercows/entities/User::toString → KILLED |
return String.format("User: id=%d email=%s",id,email); |
55 | } | |
56 | } | |
Mutations | ||
54 |
1.1 |