mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
denormalized fields on statuses for faster queries
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package com.commafeed.backend.model;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import javax.persistence.Cacheable;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
@@ -7,6 +9,8 @@ import javax.persistence.FetchType;
|
||||
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;
|
||||
@@ -30,6 +34,32 @@ public class FeedEntryStatus extends AbstractModel {
|
||||
private boolean read;
|
||||
private boolean starred;
|
||||
|
||||
/**
|
||||
* Denormalization starts here
|
||||
*/
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(nullable = false)
|
||||
private User user;
|
||||
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date entryInserted;
|
||||
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date entryUpdated;
|
||||
|
||||
public FeedEntryStatus() {
|
||||
|
||||
}
|
||||
|
||||
public FeedEntryStatus(User user, FeedSubscription subscription, FeedEntry entry) {
|
||||
setUser(user);
|
||||
setSubscription(subscription);
|
||||
setEntry(entry);
|
||||
setEntryInserted(entry.getInserted());
|
||||
setEntryUpdated(entry.getUpdated());
|
||||
}
|
||||
|
||||
public FeedSubscription getSubscription() {
|
||||
return subscription;
|
||||
}
|
||||
@@ -62,4 +92,28 @@ public class FeedEntryStatus extends AbstractModel {
|
||||
this.starred = starred;
|
||||
}
|
||||
|
||||
public Date getEntryInserted() {
|
||||
return entryInserted;
|
||||
}
|
||||
|
||||
public void setEntryInserted(Date entryInserted) {
|
||||
this.entryInserted = entryInserted;
|
||||
}
|
||||
|
||||
public Date getEntryUpdated() {
|
||||
return entryUpdated;
|
||||
}
|
||||
|
||||
public void setEntryUpdated(Date entryUpdated) {
|
||||
this.entryUpdated = entryUpdated;
|
||||
}
|
||||
|
||||
public User getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(User user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user