Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JAMES-3911 JPA: position messages index correctly #1595

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
import org.apache.james.mailbox.store.mail.model.impl.PropertyBuilder;
import org.apache.openjpa.persistence.jdbc.ElementJoinColumn;
import org.apache.openjpa.persistence.jdbc.ElementJoinColumns;
import org.apache.openjpa.persistence.jdbc.Index;

import com.github.fge.lambdas.Throwing;
import com.google.common.base.Objects;
Expand Down Expand Up @@ -165,7 +164,6 @@ public boolean equals(Object obj) {
private long uid;

/** The value for the modSeq field */
@Index
@Column(name = "MAIL_MODSEQ")
private long modSeq;

Expand All @@ -182,7 +180,6 @@ public boolean equals(Object obj) {
/** The value for the deleted field */
@Basic(optional = false)
@Column(name = "MAIL_IS_DELETED", nullable = false)
@Index
private boolean deleted = false;

/** The value for the draft field */
Expand All @@ -198,13 +195,11 @@ public boolean equals(Object obj) {
/** The value for the recent field */
@Basic(optional = false)
@Column(name = "MAIL_IS_RECENT", nullable = false)
@Index
private boolean recent = false;

/** The value for the seen field */
@Basic(optional = false)
@Column(name = "MAIL_IS_SEEN", nullable = false)
@Index
private boolean seen = false;

/** The first body octet */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Index;
import javax.persistence.Lob;
import javax.persistence.Table;

Expand All @@ -45,20 +46,26 @@
import org.apache.openjpa.persistence.Factory;

@Entity(name = "MailboxMessage")
@Table(name = "JAMES_MAIL")
@Table(name = "JAMES_MAIL",
indexes = {
@Index(name = "MAIL_IS_SEEN_INDEX", columnList = "MAILBOX_ID, MAIL_IS_SEEN"),
@Index(name = "MAIL_IS_RECENT_INDEX", columnList = "MAILBOX_ID, MAIL_IS_RECENT"),
@Index(name = "MAIL_IS_DELETED_INDEX", columnList = "MAILBOX_ID, MAIL_IS_DELETED"),
@Index(name = "MAIL_MODSEQ_INDEX", columnList = "MAILBOX_ID, MAIL_MODSEQ")
})
public class JPAEncryptedMailboxMessage extends AbstractJPAMailboxMessage {

/** The value for the body field. Lazy loaded */
/** We use a max length to represent 1gb data. Thats prolly overkill, but who knows */
/** The value for the body field. Lazy loaded
* We use a max length to represent 1gb data. Thats prolly overkill, but who knows */
@Basic(optional = false, fetch = FetchType.LAZY)
@Column(name = "MAIL_BYTES", length = 1048576000, nullable = false)
@Externalizer("EncryptDecryptHelper.getEncrypted")
@Factory("EncryptDecryptHelper.getDecrypted")
@Lob private byte[] body;


/** The value for the header field. Lazy loaded */
/** We use a max length to represent 1gb data. Thats prolly overkill, but who knows */
/** The value for the header field. Lazy loaded
* We use a max length to represent 1gb data. Thats prolly overkill, but who knows */
@Basic(optional = false, fetch = FetchType.LAZY)
@Column(name = "HEADER_BYTES", length = 10485760, nullable = false)
@Externalizer("EncryptDecryptHelper.getEncrypted")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Index;
import javax.persistence.Lob;
import javax.persistence.Table;

Expand All @@ -45,20 +46,26 @@
import com.google.common.annotations.VisibleForTesting;

@Entity(name = "MailboxMessage")
@Table(name = "JAMES_MAIL")
@Table(name = "JAMES_MAIL",
indexes = {
@Index(name = "MAIL_IS_SEEN_INDEX", columnList = "MAILBOX_ID, MAIL_IS_SEEN"),
@Index(name = "MAIL_IS_RECENT_INDEX", columnList = "MAILBOX_ID, MAIL_IS_RECENT"),
@Index(name = "MAIL_IS_DELETED_INDEX", columnList = "MAILBOX_ID, MAIL_IS_DELETED"),
@Index(name = "MAIL_MODSEQ_INDEX", columnList = "MAILBOX_ID, MAIL_MODSEQ")
})
public class JPAMailboxMessage extends AbstractJPAMailboxMessage {

private static final byte[] EMPTY_BODY = new byte[] {};

/** The value for the body field. Lazy loaded */
/** We use a max length to represent 1gb data. Thats prolly overkill, but who knows */
/** The value for the body field. Lazy loaded
* We use a max length to represent 1gb data. Thats prolly overkill, but who knows */
@Basic(optional = false, fetch = FetchType.LAZY)
@Column(name = "MAIL_BYTES", length = 1048576000, nullable = false)
@Lob private byte[] body;


/** The value for the header field. Lazy loaded */
/** We use a max length to represent 10mb data. Thats prolly overkill, but who knows */
/** The value for the header field. Lazy loaded
* We use a max length to represent 10mb data. Thats prolly overkill, but who knows */
@Basic(optional = false, fetch = FetchType.LAZY)
@Column(name = "HEADER_BYTES", length = 10485760, nullable = false)
@Lob private byte[] header;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Index;
import javax.persistence.Table;

import org.apache.commons.io.input.BoundedInputStream;
Expand All @@ -50,7 +51,13 @@
* TODO: Fix me!
*/
@Entity(name = "MailboxMessage")
@Table(name = "JAMES_MAIL")
@Table(name = "JAMES_MAIL",
indexes = {
@Index(name = "MAIL_IS_SEEN_INDEX", columnList = "MAILBOX_ID, MAIL_IS_SEEN"),
@Index(name = "MAIL_IS_RECENT_INDEX", columnList = "MAILBOX_ID, MAIL_IS_RECENT"),
@Index(name = "MAIL_IS_DELETED_INDEX", columnList = "MAILBOX_ID, MAIL_IS_DELETED"),
@Index(name = "MAIL_MODSEQ_INDEX", columnList = "MAILBOX_ID, MAIL_MODSEQ")
})
public class JPAStreamingMailboxMessage extends AbstractJPAMailboxMessage {

@Persistent(optional = false, fetch = FetchType.LAZY)
Expand Down