mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
remove many to many relationship between entries and feeds
This commit is contained in:
@@ -4,6 +4,7 @@ import java.util.Date;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.persistence.Cacheable;
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.OneToMany;
|
||||
@@ -107,8 +108,8 @@ public class Feed extends AbstractModel {
|
||||
@Column(length = 40)
|
||||
private String lastContentHash;
|
||||
|
||||
@OneToMany(mappedBy = "feed")
|
||||
private Set<FeedFeedEntry> entryRelationships;
|
||||
@OneToMany(mappedBy = "feed", cascade = CascadeType.REMOVE)
|
||||
private Set<FeedEntry> entries;
|
||||
|
||||
@OneToMany(mappedBy = "feed")
|
||||
private Set<FeedSubscription> subscriptions;
|
||||
@@ -325,12 +326,12 @@ public class Feed extends AbstractModel {
|
||||
this.normalizedUrlHash = normalizedUrlHash;
|
||||
}
|
||||
|
||||
public Set<FeedFeedEntry> getEntryRelationships() {
|
||||
return entryRelationships;
|
||||
public Set<FeedEntry> getEntries() {
|
||||
return entries;
|
||||
}
|
||||
|
||||
public void setEntryRelationships(Set<FeedFeedEntry> entryRelationships) {
|
||||
this.entryRelationships = entryRelationships;
|
||||
public void setEntries(Set<FeedEntry> entries) {
|
||||
this.entries = entries;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.OneToOne;
|
||||
import javax.persistence.Table;
|
||||
@@ -32,8 +33,8 @@ public class FeedEntry extends AbstractModel {
|
||||
@Column(length = 40, nullable = false)
|
||||
private String guidHash;
|
||||
|
||||
@OneToMany(mappedBy = "entry", cascade = CascadeType.REMOVE)
|
||||
private Set<FeedFeedEntry> feedRelationships;
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
private Feed feed;
|
||||
|
||||
@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(nullable = false, updatable = false)
|
||||
@@ -124,12 +125,12 @@ public class FeedEntry extends AbstractModel {
|
||||
this.author = author;
|
||||
}
|
||||
|
||||
public Set<FeedFeedEntry> getFeedRelationships() {
|
||||
return feedRelationships;
|
||||
public Feed getFeed() {
|
||||
return feed;
|
||||
}
|
||||
|
||||
public void setFeedRelationships(Set<FeedFeedEntry> feedRelationships) {
|
||||
this.feedRelationships = feedRelationships;
|
||||
public void setFeed(Feed feed) {
|
||||
this.feed = feed;
|
||||
}
|
||||
|
||||
public FeedSubscription getSubscription() {
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
package com.commafeed.backend.model;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.persistence.Cacheable;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Lob;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.hibernate.annotations.Cache;
|
||||
@@ -23,12 +26,21 @@ public class FeedEntryContent extends AbstractModel {
|
||||
@Column(length = Integer.MAX_VALUE)
|
||||
private String content;
|
||||
|
||||
@Column(length = 40)
|
||||
private String contentHash;
|
||||
|
||||
@Column(name = "author", length = 128)
|
||||
private String author;
|
||||
|
||||
@Column(length = 2048)
|
||||
private String enclosureUrl;
|
||||
|
||||
@Column(length = 255)
|
||||
private String enclosureType;
|
||||
|
||||
@OneToMany(mappedBy = "content")
|
||||
private Set<FeedEntry> entries;
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
@@ -61,4 +73,28 @@ public class FeedEntryContent extends AbstractModel {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getContentHash() {
|
||||
return contentHash;
|
||||
}
|
||||
|
||||
public void setContentHash(String contentHash) {
|
||||
this.contentHash = contentHash;
|
||||
}
|
||||
|
||||
public String getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
||||
public void setAuthor(String author) {
|
||||
this.author = author;
|
||||
}
|
||||
|
||||
public Set<FeedEntry> getEntries() {
|
||||
return entries;
|
||||
}
|
||||
|
||||
public void setEntries(Set<FeedEntry> entries) {
|
||||
this.entries = entries;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
package com.commafeed.backend.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.persistence.Cacheable;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
|
||||
import org.hibernate.annotations.Cache;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
|
||||
@Entity
|
||||
@Table(name = "FEED_FEEDENTRIES")
|
||||
@SuppressWarnings("serial")
|
||||
@Cacheable
|
||||
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
|
||||
public class FeedFeedEntry implements Serializable {
|
||||
|
||||
@Id
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "FEED_ID")
|
||||
private Feed feed;
|
||||
|
||||
@Id
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "FEEDENTRY_ID")
|
||||
private FeedEntry entry;
|
||||
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date entryUpdated;
|
||||
|
||||
public FeedFeedEntry() {
|
||||
|
||||
}
|
||||
|
||||
public FeedFeedEntry(Feed feed, FeedEntry entry) {
|
||||
this.feed = feed;
|
||||
this.entry = entry;
|
||||
this.entryUpdated = entry.getUpdated();
|
||||
}
|
||||
|
||||
public Feed getFeed() {
|
||||
return feed;
|
||||
}
|
||||
|
||||
public void setFeed(Feed feed) {
|
||||
this.feed = feed;
|
||||
}
|
||||
|
||||
public FeedEntry getEntry() {
|
||||
return entry;
|
||||
}
|
||||
|
||||
public void setEntry(FeedEntry entry) {
|
||||
this.entry = entry;
|
||||
}
|
||||
|
||||
public Date getEntryUpdated() {
|
||||
return entryUpdated;
|
||||
}
|
||||
|
||||
public void setEntryUpdated(Date entryUpdated) {
|
||||
this.entryUpdated = entryUpdated;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user