queries optimization

This commit is contained in:
Athou
2013-04-07 16:19:35 +02:00
parent f7e636d105
commit 55801d914f
5 changed files with 44 additions and 14 deletions

View File

@@ -5,7 +5,6 @@ import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.Lob;
@@ -27,7 +26,7 @@ public class FeedEntry extends AbstractModel {
@Column(length = 2048, nullable = false)
private String guid;
@ManyToMany(fetch = FetchType.EAGER)
@ManyToMany
@JoinTable(name = "FEED_FEEDENTRIES", joinColumns = { @JoinColumn(name = "FEED_ID", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "FEEDENTRY_ID", nullable = false, updatable = false) })
private Set<Feed> feeds = Sets.newHashSet();

View File

@@ -1,5 +1,8 @@
package com.commafeed.backend.model.extended;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import com.commafeed.backend.model.FeedEntry;
import com.commafeed.backend.model.FeedEntryStatus;
@@ -12,6 +15,31 @@ public class FeedEntryWithStatus {
this.status = status;
}
@Override
public int hashCode() {
return new HashCodeBuilder(17, 37).append(entry.getId())
.append(status == null ? null : status.getId()).toHashCode();
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (obj == this) {
return true;
}
if (obj.getClass() != getClass()) {
return false;
}
FeedEntryWithStatus rhs = (FeedEntryWithStatus) obj;
return new EqualsBuilder()
.append(status == null ? null : status.getId(),
rhs.status == null ? null : rhs.status.getId())
.append(entry.getId(), rhs.entry.getId()).isEquals();
}
public FeedEntry getEntry() {
return entry;
}