Skip to content

Instantly share code, notes, and snippets.

@jordanbaucke
Created October 31, 2017 18:48
Show Gist options
  • Save jordanbaucke/125f7a47eb224aeeb25d4b40ecf41f6e to your computer and use it in GitHub Desktop.
Save jordanbaucke/125f7a47eb224aeeb25d4b40ecf41f6e to your computer and use it in GitHub Desktop.
@Entity
@Table(name = "user")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@Document(indexName = "user")
@NamedEntityGraph(name = "User.activeLobbyStreams",
attributeNodes = @NamedAttributeNode(value = "activeLobbyStreams", subgraph = "activeLobbyStreams"),
subgraphs = @NamedSubgraph(name = "activeLobbyStreams", attributeNodes = @NamedAttributeNode("lobby")))
public class User extends AbstractAuditingEntity implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@NotNull
@Pattern(regexp = Constants.LOGIN_REGEX)
@Size(min = 1, max = 100)
@Column(length = 100, unique = true, nullable = false)
private String login;
@JsonIgnore
@NotNull
@Size(min = 60, max = 60)
@Column(name = "password_hash", length = 60)
private String password;
@Size(max = 50)
@Column(name = "first_name", length = 50)
private String firstName;
@Size(max = 50)
@Column(name = "last_name", length = 50)
private String lastName;
@Email
@Size(max = 100)
@Column(length = 100, unique = true)
private String email;
@NotNull
@Column(nullable = false)
private boolean activated = false;
@Size(min = 2, max = 5)
@Column(name = "lang_key", length = 5)
private String langKey;
@Size(max = 20)
@Column(name = "activation_key", length = 20)
@JsonIgnore
private String activationKey;
@Size(max = 20)
@Column(name = "reset_key", length = 20)
private String resetKey;
@Column(name = "reset_date", nullable = true)
private ZonedDateTime resetDate = null;
@JsonIgnore
@ManyToMany(fetch = FetchType.EAGER)
@JoinTable(
name = "ev_user_authority",
joinColumns = {@JoinColumn(name = "user_id", referencedColumnName = "id")},
inverseJoinColumns = {@JoinColumn(name = "authority_name", referencedColumnName = "name")})
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
private Set<Authority> authorities = new HashSet<>();
@Column(name = "description")
private String description;
@Column(name = "online")
private Boolean online = false;
@Column(name = "avatar_url")
private String avatarUrl = "https://s3.amazonaws.com/evasyst-defaults/blank-profile.jpg";
@Column(name = "banner_url")
private String bannerUrl = "https://s3.amazonaws.com/evasyst-defaults/default-user-banner.png";
@OneToOne(mappedBy = "user", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY)
private UserProfile userProfile;
@Column(name = "test_data")
private Boolean testData = false;
@OneToMany(mappedBy = "recipient", cascade = CascadeType.ALL)
private Set<FriendshipRequest> pendingFriendshipRequests;
@OneToMany(mappedBy = "requester", cascade = CascadeType.ALL)
private Set<FriendshipRequest> sendFriendshipRequests;
@JsonIgnore
@OneToMany(mappedBy = "owner", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
private List<Friendship> friendships = new ArrayList<>();
@JsonIgnore
@OneToMany(mappedBy = "user", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@Where(clause = "status='ESTABLISHED'")
@OrderBy("lastModifiedDate DESC")
private List<LobbyStream> activeLobbyStreams = new ArrayList<>();
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment