User는 대략 아래와 같은 형태입니다.
@Entity
@Cacheable
@Table(name = "users")
public class User implements Serializable {
@Transient
protected Logger logger = LoggerFactory.getLogger(getClass());
private static final long serialVersionUID = -6961998490722195548L;
public User(String nickname) {
this();
this.nickname = nickname;
}
public User() {
super();
this.reset();
}
public User(Long id) {
this();
this.id = id;
}
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
public Long getId() {
return id;
}
@Column(unique = true, nullable = false, length = 50)
private String nickname;
public String getNickname() {
return nickname;
}
public void setNickname(String nickname) {
this.nickname = nickname;
}
@JsonIgnore
@JoinColumn(name = "user_id")
@OneToMany(targetEntity = App.class, cascade = CascadeType.REMOVE, fetch = FetchType.EAGER)
private Set<App> apps;
public Set<App> getApps() {
return apps;
}
public void setApps(Set<App> tokens) {
this.apps = tokens;
}
@JsonIgnore
@Column(name = "updated_at")
@Temporal(TemporalType.TIMESTAMP)
private Date updatedAt;
public void setUpdatedAt(Date updatedAt) {
this.updatedAt = updatedAt;
}
public Date getUpdatedAt() {
return updatedAt;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((id == null) ? 0 : id.hashCode());
result = prime * result + ((nickname == null) ? 0 : nickname.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
User other = (User) obj;
if (id == null) {
if (
other.id != null)
return false;
} else if (!id.equals(
other.id))
return false;
if (nickname == null) {
if (other.nickname != null)
return false;
} else if (!nickname.equals(other.nickname))
return false;
return true;
}
}