forked from Archives/Athou_commafeed
added indexes and constraints
This commit is contained in:
@@ -75,11 +75,10 @@ public class OPMLImporter {
|
||||
sub = new FeedSubscription();
|
||||
sub.setFeed(feed);
|
||||
sub.setUser(user);
|
||||
feedSubscriptionService.save(sub);
|
||||
}
|
||||
sub.setCategory(parent);
|
||||
sub.setTitle(outline.getText());
|
||||
feedSubscriptionService.update(sub);
|
||||
feedSubscriptionService.saveOrUpdate(sub);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ import javax.persistence.Table;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
|
||||
import org.hibernate.annotations.Index;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
@Entity
|
||||
@@ -17,7 +19,8 @@ import com.google.common.collect.Sets;
|
||||
@SuppressWarnings("serial")
|
||||
public class Feed extends AbstractModel {
|
||||
|
||||
@Column(length = 2048)
|
||||
@Column(length = 2048, nullable = false, unique = true)
|
||||
@Index(name = "feed_index")
|
||||
private String url;
|
||||
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.util.Set;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Table;
|
||||
@@ -15,10 +16,11 @@ import com.google.common.collect.Sets;
|
||||
@SuppressWarnings("serial")
|
||||
public class FeedCategory extends AbstractModel {
|
||||
|
||||
@Column(length = 128)
|
||||
@Column(length = 128, nullable = false)
|
||||
private String name;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(nullable = false)
|
||||
private User user;
|
||||
|
||||
@ManyToOne
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.util.Set;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.Lob;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.OneToMany;
|
||||
@@ -13,16 +14,19 @@ import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
|
||||
import org.apache.commons.codec.binary.StringUtils;
|
||||
import org.hibernate.annotations.Index;
|
||||
|
||||
@Entity
|
||||
@Table(name = "FEEDENTRIES")
|
||||
@SuppressWarnings("serial")
|
||||
public class FeedEntry extends AbstractModel {
|
||||
|
||||
@Column(length = 2048)
|
||||
@Column(length = 2048, nullable = false, unique = true)
|
||||
@Index(name = "guid_index")
|
||||
private String guid;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(nullable = false)
|
||||
private Feed feed;
|
||||
|
||||
@Column(length = 2048)
|
||||
@@ -35,6 +39,7 @@ public class FeedEntry extends AbstractModel {
|
||||
private String url;
|
||||
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
@Index(name = "updated_index")
|
||||
private Date updated;
|
||||
|
||||
@OneToMany(mappedBy = "entry")
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.commafeed.backend.model;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@@ -11,9 +12,11 @@ import javax.persistence.Table;
|
||||
public class FeedEntryStatus extends AbstractModel {
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(nullable = false)
|
||||
private User user;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(nullable = false)
|
||||
private FeedEntry entry;
|
||||
|
||||
@Column(name = "read_status")
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.commafeed.backend.model;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@@ -11,12 +12,14 @@ import javax.persistence.Table;
|
||||
public class FeedSubscription extends AbstractModel {
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(nullable = false)
|
||||
private User user;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(nullable = false)
|
||||
private Feed feed;
|
||||
|
||||
@Column(length = 128)
|
||||
@Column(length = 128, nullable = false)
|
||||
private String title;
|
||||
|
||||
@ManyToOne
|
||||
|
||||
@@ -8,6 +8,8 @@ import javax.persistence.Entity;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.hibernate.annotations.Index;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
@Entity
|
||||
@@ -15,13 +17,14 @@ import com.google.common.collect.Sets;
|
||||
@SuppressWarnings("serial")
|
||||
public class User extends AbstractModel {
|
||||
|
||||
@Column(length = 32)
|
||||
@Column(length = 32, nullable = false, unique = true)
|
||||
@Index(name = "username_index")
|
||||
private String name;
|
||||
|
||||
@Column(length = 256)
|
||||
@Column(length = 256, nullable = false)
|
||||
private byte[] password;
|
||||
|
||||
@Column(length = 8)
|
||||
@Column(length = 8, nullable = false)
|
||||
private byte[] salt;
|
||||
|
||||
@OneToMany(mappedBy = "user", cascade = CascadeType.PERSIST)
|
||||
|
||||
@@ -12,10 +12,10 @@ import javax.persistence.Table;
|
||||
public class UserRole extends AbstractModel {
|
||||
|
||||
@OneToOne
|
||||
@JoinColumn(name = "user_id")
|
||||
@JoinColumn(name = "user_id", nullable = false)
|
||||
private User user;
|
||||
|
||||
@Column(name = "roleName")
|
||||
@Column(name = "roleName", nullable = false)
|
||||
private String role;
|
||||
|
||||
public UserRole() {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.commafeed.backend.model;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EnumType;
|
||||
import javax.persistence.Enumerated;
|
||||
@@ -17,10 +18,11 @@ public class UserSettings extends AbstractModel {
|
||||
}
|
||||
|
||||
@OneToOne
|
||||
@JoinColumn(name = "user_id")
|
||||
@JoinColumn(name = "user_id", nullable = false)
|
||||
private User user;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(nullable = false)
|
||||
private ReadingMode readingMode;
|
||||
|
||||
public ReadingMode getReadingMode() {
|
||||
|
||||
Reference in New Issue
Block a user