2013-03-23 16:17:19 +01:00
|
|
|
package com.commafeed.backend.model;
|
2013-03-20 20:33:42 +01:00
|
|
|
|
2013-04-18 16:58:56 +02:00
|
|
|
import java.util.Date;
|
2013-03-28 17:07:37 +01:00
|
|
|
import java.util.Set;
|
|
|
|
|
|
2013-06-19 18:44:56 +02:00
|
|
|
import javax.persistence.Cacheable;
|
2013-03-28 17:07:37 +01:00
|
|
|
import javax.persistence.CascadeType;
|
2013-03-20 20:33:42 +01:00
|
|
|
import javax.persistence.Column;
|
|
|
|
|
import javax.persistence.Entity;
|
2013-06-16 18:03:52 +02:00
|
|
|
import javax.persistence.FetchType;
|
2013-03-28 17:07:37 +01:00
|
|
|
import javax.persistence.OneToMany;
|
2013-03-20 20:33:42 +01:00
|
|
|
import javax.persistence.Table;
|
2013-04-18 16:58:56 +02:00
|
|
|
import javax.persistence.Temporal;
|
|
|
|
|
import javax.persistence.TemporalType;
|
2013-03-20 20:33:42 +01:00
|
|
|
|
2013-08-11 12:09:05 +02:00
|
|
|
import lombok.Data;
|
|
|
|
|
import lombok.EqualsAndHashCode;
|
|
|
|
|
|
2013-06-19 18:44:56 +02:00
|
|
|
import org.hibernate.annotations.Cache;
|
|
|
|
|
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
|
|
|
|
|
2013-03-28 17:07:37 +01:00
|
|
|
import com.google.common.collect.Sets;
|
|
|
|
|
|
2013-03-20 20:33:42 +01:00
|
|
|
@Entity
|
|
|
|
|
@Table(name = "USERS")
|
2013-03-21 08:55:53 +01:00
|
|
|
@SuppressWarnings("serial")
|
2013-06-19 18:44:56 +02:00
|
|
|
@Cacheable
|
|
|
|
|
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
|
2013-08-11 12:09:05 +02:00
|
|
|
@Data
|
|
|
|
|
@EqualsAndHashCode(callSuper = true)
|
2013-03-23 01:49:39 +01:00
|
|
|
public class User extends AbstractModel {
|
2013-03-20 20:33:42 +01:00
|
|
|
|
2013-03-29 11:51:27 +01:00
|
|
|
@Column(length = 32, nullable = false, unique = true)
|
2013-03-20 20:33:42 +01:00
|
|
|
private String name;
|
|
|
|
|
|
2013-04-06 08:17:25 +02:00
|
|
|
@Column(length = 255, unique = true)
|
2013-04-05 16:31:42 +02:00
|
|
|
private String email;
|
|
|
|
|
|
2013-03-29 11:51:27 +01:00
|
|
|
@Column(length = 256, nullable = false)
|
2013-03-20 20:33:42 +01:00
|
|
|
private byte[] password;
|
|
|
|
|
|
2013-05-01 21:56:59 +02:00
|
|
|
@Column(length = 40, unique = true)
|
|
|
|
|
private String apiKey;
|
|
|
|
|
|
2013-03-29 11:51:27 +01:00
|
|
|
@Column(length = 8, nullable = false)
|
2013-03-20 20:33:42 +01:00
|
|
|
private byte[] salt;
|
|
|
|
|
|
2013-03-29 12:59:21 +01:00
|
|
|
@Column(nullable = false)
|
|
|
|
|
private boolean disabled;
|
|
|
|
|
|
2013-04-18 16:58:56 +02:00
|
|
|
@Temporal(TemporalType.TIMESTAMP)
|
|
|
|
|
private Date lastLogin;
|
|
|
|
|
|
2013-06-16 18:31:21 +02:00
|
|
|
@Temporal(TemporalType.TIMESTAMP)
|
|
|
|
|
private Date created;
|
|
|
|
|
|
2013-05-20 21:53:13 +02:00
|
|
|
@Column(length = 40)
|
|
|
|
|
private String recoverPasswordToken;
|
|
|
|
|
|
|
|
|
|
@Temporal(TemporalType.TIMESTAMP)
|
|
|
|
|
private Date recoverPasswordTokenDate;
|
|
|
|
|
|
2013-07-25 09:17:33 +02:00
|
|
|
@OneToMany(mappedBy = "user", cascade = { CascadeType.PERSIST, CascadeType.REMOVE })
|
2013-03-28 17:07:37 +01:00
|
|
|
private Set<UserRole> roles = Sets.newHashSet();
|
|
|
|
|
|
2013-06-16 18:31:21 +02:00
|
|
|
@OneToMany(mappedBy = "user", fetch = FetchType.LAZY, cascade = CascadeType.REMOVE)
|
2013-06-16 18:03:52 +02:00
|
|
|
private Set<FeedSubscription> subscriptions;
|
|
|
|
|
|
2013-03-20 20:33:42 +01:00
|
|
|
}
|