Author: eric
Date: Thu Jan 13 12:11:50 2011
New Revision: 1058528

URL: http://svn.apache.org/viewvc?rev=1058528&view=rev
Log:
Name JPA tables and columns (MAILBOX-14)

Modified:
    
james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/JPAHeader.java
    
james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/JPAMailbox.java
    
james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/JPAProperty.java
    
james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/openjpa/AbstractJPAMailboxMembership.java
    
james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/openjpa/AbstractJPAMessage.java
    
james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/openjpa/JPAMailboxMembership.java
    
james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/openjpa/JPAMessage.java
    
james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/openjpa/JPAStreamingMailboxMembership.java
    
james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/openjpa/JPAStreamingMessage.java
    
james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/user/model/JPASubscription.java

Modified: 
james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/JPAHeader.java
URL: 
http://svn.apache.org/viewvc/james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/JPAHeader.java?rev=1058528&r1=1058527&r2=1058528&view=diff
==============================================================================
--- 
james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/JPAHeader.java
 (original)
+++ 
james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/JPAHeader.java
 Thu Jan 13 12:11:50 2011
@@ -23,29 +23,39 @@ import javax.persistence.Column;
 import javax.persistence.Entity;
 import javax.persistence.GeneratedValue;
 import javax.persistence.Id;
+import javax.persistence.Table;
 
 import org.apache.james.mailbox.store.mail.model.AbstractComparableHeader;
 import org.apache.james.mailbox.store.mail.model.Header;
 
-@Entity(name="Header")
+@Entity(name = "Header")
+@Table(name = "JAMES_MAIL_HEADER")
 public class JPAHeader extends AbstractComparableHeader {
     
     private static final String TOSTRING_SEP = " ";
 
-    @Id @GeneratedValue private long id;
+    @Id
+    @GeneratedValue
+    @Column(name = "HEADER_ID", nullable = false)
+    private long id;
 
     /** The value for the lineNumber field */
-    @Basic(optional=false) private int lineNumber;
+    @Basic(optional=false)
+    @Column(name = "HEADER_LINE_NUMBER", nullable = false)
+    private int lineNumber;
 
     /** The value for the field field */
     /** Use a max of 1024 which could happen on very freaky header field 
names*/
-    @Column(length=1024)
-    @Basic(optional=false) private String field;
+    @Basic(optional=false)
+    @Column(name = "HEADER_FIELD", nullable = false, length = 1024)
+    private String field;
 
     /** The value for the value field */
-    /** We use 10240 as max which is mostly overkill for most emails but 
better waste a bit of space then loose headers**/
-    @Column(length=10240)
-    @Basic(optional=false) private String value;
+    /** We use 4000 as max which is mostly overkill for most emails but better 
waste a bit of space then loose headers**/
+    /** 4000 is the maximum value accepted by Oracle for VARCHAR2 **/
+    @Basic(optional=false)
+    @Column(name = "HEADER_VALUE", nullable = false, length = 4000)
+    private String value;
     
     /**
      * For JPA use only.
@@ -111,8 +121,7 @@ public class JPAHeader extends AbstractC
         return true;
     }
 
-    public String toString()
-    {
+    public String toString() {
         final String retValue =  "Header ( "
             + "id = " + this.id + TOSTRING_SEP
             + "lineNumber = " + this.lineNumber + TOSTRING_SEP

Modified: 
james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/JPAMailbox.java
URL: 
http://svn.apache.org/viewvc/james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/JPAMailbox.java?rev=1058528&r1=1058527&r2=1058528&view=diff
==============================================================================
--- 
james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/JPAMailbox.java
 (original)
+++ 
james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/JPAMailbox.java
 Thu Jan 13 12:11:50 2011
@@ -25,11 +25,13 @@ import javax.persistence.GeneratedValue;
 import javax.persistence.Id;
 import javax.persistence.NamedQueries;
 import javax.persistence.NamedQuery;
+import javax.persistence.Table;
 
 import org.apache.james.mailbox.MailboxPath;
 import org.apache.james.mailbox.store.mail.model.Mailbox;
 
 @Entity(name="Mailbox")
+@Table(name="JAMES_MAILBOX")
 @NamedQueries({
     @NamedQuery(name="findMailboxById",
         query="SELECT mailbox FROM Mailbox mailbox WHERE mailbox.mailboxId = 
:idParam"),
@@ -55,16 +57,28 @@ public class JPAMailbox implements Mailb
     private static final String TAB = " ";
 
     /** The value for the mailboxId field */
-    @Id @GeneratedValue private long mailboxId;
+    @Id
+    @GeneratedValue
+    @Column(name = "MAILBOX_ID", nullable = false)
+    private long mailboxId;
     
     /** The value for the name field */
-    @Basic(optional=false) @Column(nullable = false) private String name;
+    @Basic(optional=false)
+    @Column(name = "MAILBOX_NAME", nullable = false, length = 200)
+    private String name;
 
     /** The value for the uidValidity field */
-    @Basic(optional=false) private long uidValidity;
-
-    @Basic(optional=false) @Column(nullable = true)  private String user;
-    @Basic(optional=false) @Column(nullable = false) private String namespace;
+    @Basic(optional=false)
+    @Column(name = "MAILBOX_UID_VALIDITY", nullable = false)
+    private long uidValidity;
+
+    @Basic(optional=false)
+    @Column(name = "USER_NAME", nullable = true, length = 200)
+    private String user;
+    
+    @Basic(optional=false)
+    @Column(name = "MAILBOX_NAMESPACE", nullable = false, length = 200)
+    private String namespace;
 
     /**
      * JPA only
@@ -96,14 +110,12 @@ public class JPAMailbox implements Mailb
         return name;
     }
 
-
     /**
      * @see org.apache.james.mailbox.store.mail.model.Mailbox#getUidValidity()
      */
     public long getUidValidity() {
         return uidValidity;
     }
-
     
     /**
      * @see 
org.apache.james.mailbox.store.mail.model.Mailbox#setName(java.lang.String)
@@ -113,8 +125,7 @@ public class JPAMailbox implements Mailb
     }
 
     @Override
-    public String toString()
-    {
+    public String toString() {
         final String retValue = "Mailbox ( "
             + "mailboxId = " + this.mailboxId + TAB
             + "name = " + this.name + TAB
@@ -169,7 +180,6 @@ public class JPAMailbox implements Mailb
         this.namespace = namespace;
     }
 
-
     /*
      * (non-Javadoc)
      * @see 
org.apache.james.mailbox.store.mail.model.Mailbox#setUser(java.lang.String)
@@ -177,4 +187,5 @@ public class JPAMailbox implements Mailb
     public void setUser(String user) {
         this.user = user;
     }
+    
 }

Modified: 
james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/JPAProperty.java
URL: 
http://svn.apache.org/viewvc/james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/JPAProperty.java?rev=1058528&r1=1058527&r2=1058528&view=diff
==============================================================================
--- 
james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/JPAProperty.java
 (original)
+++ 
james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/JPAProperty.java
 Thu Jan 13 12:11:50 2011
@@ -19,26 +19,44 @@
 package org.apache.james.mailbox.jpa.mail.model;
 
 import javax.persistence.Basic;
+import javax.persistence.Column;
 import javax.persistence.Entity;
 import javax.persistence.GeneratedValue;
 import javax.persistence.Id;
+import javax.persistence.Table;
 
 import org.apache.james.mailbox.store.mail.model.AbstractComparableProperty;
 import org.apache.james.mailbox.store.mail.model.Property;
 
 @Entity(name="Property")
+@Table(name="JAMES_MAIL_PROPERTY")
 public class JPAProperty extends AbstractComparableProperty<JPAProperty> {
 
-    @Id @GeneratedValue private long id;
+    /** The system unique key */
+    @Id
+    @GeneratedValue
+    @Column(name = "PROPERTY_ID", nullable = false)
+    private long id;
     
     /** Order within the list of properties */
-    @Basic(optional=false) private int line;
+    @Basic(optional=false)
+    @Column(name = "PROPERTY_LINE_NUMBER", nullable = false)
+    private int line;
+    
     /** Local part of the name of this property */
-    @Basic(optional=false) private String localName;
+    @Basic(optional=false)
+    @Column(name = "PROPERTY_LOCAL_NAME", nullable = false, length = 200)
+    private String localName;
+    
     /** Namespace part of the name of this property */
-    @Basic(optional=false) private String namespace;
+    @Basic(optional=false)
+    @Column(name = "PROPERTY_NAME_SPACE", nullable = false, length = 200)
+    private String namespace;
+
     /** Value of this property */
-    @Basic(optional=false) private String value;
+    @Basic(optional=false)
+    @Column(name = "PROPERTY_VALUE", nullable = false, length = 200)
+    private String value;
     
     /**
      * @deprecated enhancement only

Modified: 
james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/openjpa/AbstractJPAMailboxMembership.java
URL: 
http://svn.apache.org/viewvc/james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/openjpa/AbstractJPAMailboxMembership.java?rev=1058528&r1=1058527&r2=1058528&view=diff
==============================================================================
--- 
james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/openjpa/AbstractJPAMailboxMembership.java
 (original)
+++ 
james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/openjpa/AbstractJPAMailboxMembership.java
 Thu Jan 13 12:11:50 2011
@@ -25,6 +25,7 @@ import java.util.List;
 
 import javax.mail.Flags;
 import javax.persistence.Basic;
+import javax.persistence.Column;
 import javax.persistence.Id;
 import javax.persistence.IdClass;
 import javax.persistence.MappedSuperclass;
@@ -76,14 +77,17 @@ public abstract class AbstractJPAMailbox
 
     /** Identifies composite key */
     public static class MailboxIdUidKey implements Serializable {
+
         private static final long serialVersionUID = 7847632032426660997L;
+        
+        public MailboxIdUidKey() {}
+
         /** The value for the mailboxId field */
         public long mailboxId;
+        
         /** The value for the uid field */
         public long uid;
 
-        public MailboxIdUidKey() {}
-
         @Override
         public int hashCode() {
             final int PRIME = 31;
@@ -111,32 +115,52 @@ public abstract class AbstractJPAMailbox
     }
 
     /** The value for the mailboxId field */
-    @Id private long mailboxId;
+    @Id
+    @Column(name = "MAILBOX_ID", nullable = false)
+    private long mailboxId;
 
     /** The value for the uid field */
-    @Id private long uid;
+    @Id
+    @Column(name = "MAIL_UID", nullable = false)
+    private long uid;
 
     /** The value for the internalDate field */
-    @Basic(optional=false) private Date internalDate;
+    @Basic(optional = false)
+    @Column(name = "MAIL_DATE", nullable = true)
+    private Date internalDate;
 
     /** The value for the answered field */
-    @Basic(optional=false) private boolean answered = false;
+    @Basic(optional = false)
+    @Column(name = "MAIL_IS_ANSWERED", nullable = true)
+    private boolean answered = false;
 
     /** The value for the deleted field */
-    @Basic(optional=false) @Index private boolean deleted = false;
+    @Basic(optional = false)
+    @Column(name = "MAIL_IS_DELETED", nullable = true)
+    @Index
+    private boolean deleted = false;
 
     /** The value for the draft field */
-    @Basic(optional=false) private boolean draft = false;
+    @Basic(optional = false)
+    @Column(name = "MAIL_IS_DRAFT", nullable = true)
+    private boolean draft = false;
 
     /** The value for the flagged field */
-    @Basic(optional=false) private boolean flagged = false;
+    @Basic(optional = false)
+    @Column(name = "MAIL_IS_FLAGGED", nullable = true)
+    private boolean flagged = false;
 
     /** The value for the recent field */
-    @Basic(optional=false) @Index private boolean recent = false;
+    @Basic(optional = false)
+    @Column(name = "MAIL_IS_RECENT", nullable = true)
+    @Index
+    private boolean recent = false;
 
     /** The value for the seen field */
-    @Basic(optional=false) @Index private boolean seen = false;
-
+    @Basic(optional = false)
+    @Column(name = "MAIL_IS_SEEN", nullable = true)
+    @Index
+    private boolean seen = false;
     
     /**
      * For enhancement only.
@@ -236,7 +260,9 @@ public abstract class AbstractJPAMailbox
         return seen;
     }
     
-
+    public void setUid(long uid) {
+        this.uid = uid;
+    }
     
     /**
      * @see 
org.apache.james.mailbox.store.mail.model.MailboxMembership#setFlags(javax.mail.Flags)
@@ -250,8 +276,6 @@ public abstract class AbstractJPAMailbox
         seen = flags.contains(Flags.Flag.SEEN);
     }
 
-  
-
     @Override
     public int hashCode() {
         final int PRIME = 31;
@@ -277,11 +301,10 @@ public abstract class AbstractJPAMailbox
         return true;
     }
 
-    public String toString()
-    {
+    public String toString() {
         final String retValue = 
             "mailbox("
-            + "mailboxId = " + this.mailboxId + TOSTRING_SEPARATOR
+            + "mailboxId = " + this.getMailboxId() + TOSTRING_SEPARATOR
             + "uid = " + this.uid + TOSTRING_SEPARATOR
             + "internalDate = " + this.internalDate + TOSTRING_SEPARATOR
             + "answered = " + this.answered + TOSTRING_SEPARATOR
@@ -291,11 +314,7 @@ public abstract class AbstractJPAMailbox
             + "recent = " + this.recent + TOSTRING_SEPARATOR
             + "seen = " + this.seen + TOSTRING_SEPARATOR
             + " )";
-
         return retValue;
     }
     
-    public void setUid(long uid) {
-        this.uid = uid;
-    }
 }

Modified: 
james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/openjpa/AbstractJPAMessage.java
URL: 
http://svn.apache.org/viewvc/james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/openjpa/AbstractJPAMessage.java?rev=1058528&r1=1058527&r2=1058528&view=diff
==============================================================================
--- 
james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/openjpa/AbstractJPAMessage.java
 (original)
+++ 
james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/openjpa/AbstractJPAMessage.java
 Thu Jan 13 12:11:50 2011
@@ -23,6 +23,7 @@ import java.util.List;
 
 import javax.persistence.Basic;
 import javax.persistence.CascadeType;
+import javax.persistence.Column;
 import javax.persistence.FetchType;
 import javax.persistence.GeneratedValue;
 import javax.persistence.Id;
@@ -44,25 +45,48 @@ import org.apache.openjpa.persistence.jd
  *
  */
 @MappedSuperclass
-public abstract class AbstractJPAMessage extends AbstractMessage{
+public abstract class AbstractJPAMessage extends AbstractMessage {
 
-    @Id@GeneratedValue private long id;
-
-    /** Headers for this message */
-    @OneToMany(cascade = CascadeType.ALL, fetch=FetchType.LAZY) 
@ElementJoinColumn(name="MESSAGE_ID") private List<JPAHeader> headers;
+    @Id
+    @GeneratedValue
+    @Column(name = "MAIL_ID", nullable = false)
+    private long id;
+    
     /** The first body octet */
-    @Basic(optional=false) private int bodyStartOctet;
+    @Basic(optional=false)
+    @Column(name = "MAIL_BODY_START_OCTET", nullable = false)
+    private int bodyStartOctet;
+    
     /** Number of octets in the full document content */
-    @Basic(optional=false) private long contentOctets;
+    @Basic(optional=false)
+    @Column(name = "MAIL_CONTENT_OCTETS_COUNT", nullable = false)
+    private long contentOctets;
+    
     /** MIME media type */
-    @Basic(optional=true) private String mediaType;
+    @Basic(optional=true)
+    @Column(name = "MAIL_MIME_TYPE", nullable = true, length = 200)
+    private String mediaType;
+    
     /** MIME sub type */
-    @Basic(optional=true) private String subType;
-    /** Meta data for this message */
-    @OneToMany(cascade = CascadeType.ALL, fetch=FetchType.LAZY) 
@OrderBy("line") @ElementJoinColumn(name="MESSAGE_ID") private 
List<JPAProperty> properties;
+    @Basic(optional=true)
+    @Column(name = "MAIL_MIME_SUBTYPE", nullable = true, length = 200)
+    private String subType;
+    
     /** THE CRFL count when this document is textual, null otherwise */
-    @Basic(optional=true) private Long textualLineCount;
+    @Basic(optional=true)
+    @Column(name = "MAIL_TEXTUAL_LINE_COUNT", nullable = true)
+    private Long textualLineCount;
     
+    /** Headers for this message */
+    @OneToMany(cascade = CascadeType.ALL, fetch=FetchType.LAZY)
+    @ElementJoinColumn(name="MAIL_ID")
+    private List<JPAHeader> headers;
+
+    /** Meta data for this message */
+    @OneToMany(cascade = CascadeType.ALL, fetch=FetchType.LAZY)
+    @OrderBy("line")
+    @ElementJoinColumn(name="MAIL_ID")
+    private List<JPAProperty> properties;
 
     @Deprecated
     public AbstractJPAMessage() {}
@@ -81,7 +105,6 @@ public abstract class AbstractJPAMessage
         for (final Property property:properties) {
             this.properties.add(new JPAProperty(property, order++));
         }
-
     }
 
     /**
@@ -120,7 +143,6 @@ public abstract class AbstractJPAMessage
         return new ArrayList<Header>(headers);
     }
 
-
     @Override
     public int hashCode() {
         final int PRIME = 31;
@@ -143,8 +165,7 @@ public abstract class AbstractJPAMessage
         return true;
     }
 
-    public String toString()
-    {
+    public String toString() {
         final String retValue = 
             "message("
             + "id = " + id
@@ -189,7 +210,6 @@ public abstract class AbstractJPAMessage
         return textualLineCount;
     }
 
-
     /*
      * (non-Javadoc)
      * @see 
org.apache.james.mailbox.store.mail.model.Document#getFullContentOctets()

Modified: 
james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/openjpa/JPAMailboxMembership.java
URL: 
http://svn.apache.org/viewvc/james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/openjpa/JPAMailboxMembership.java?rev=1058528&r1=1058527&r2=1058528&view=diff
==============================================================================
--- 
james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/openjpa/JPAMailboxMembership.java
 (original)
+++ 
james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/openjpa/JPAMailboxMembership.java
 Thu Jan 13 12:11:50 2011
@@ -25,23 +25,28 @@ import java.util.List;
 
 import javax.mail.Flags;
 import javax.persistence.CascadeType;
+import javax.persistence.Column;
 import javax.persistence.Entity;
 import javax.persistence.FetchType;
 import javax.persistence.ManyToOne;
+import javax.persistence.Table;
 
 import org.apache.james.mailbox.MailboxException;
 import org.apache.james.mailbox.jpa.mail.model.JPAHeader;
+import org.apache.james.mailbox.jpa.mail.model.JPAMailbox;
+import org.apache.james.mailbox.store.mail.model.Mailbox;
 import org.apache.james.mailbox.store.mail.model.Message;
 import org.apache.james.mailbox.store.mail.model.PropertyBuilder;
 
 @Entity(name="Membership")
-public class JPAMailboxMembership extends AbstractJPAMailboxMembership{
-
+@Table(name="JAMES_MAILBOX_MEMBERSHIP")
+public class JPAMailboxMembership extends AbstractJPAMailboxMembership {
 
     /** The value for the body field. Lazy loaded */
-    @ManyToOne(cascade = CascadeType.ALL, fetch=FetchType.LAZY) private 
JPAMessage message;
+    @ManyToOne(cascade = CascadeType.ALL, fetch=FetchType.LAZY)
+    @Column(name = "MAIL_ID", nullable = false)
+    private JPAMessage message;
   
-    
     /**
      * For enhancement only.
      */
@@ -75,5 +80,4 @@ public class JPAMailboxMembership extend
         return message;
     }
     
-
 }

Modified: 
james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/openjpa/JPAMessage.java
URL: 
http://svn.apache.org/viewvc/james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/openjpa/JPAMessage.java?rev=1058528&r1=1058527&r2=1058528&view=diff
==============================================================================
--- 
james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/openjpa/JPAMessage.java
 (original)
+++ 
james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/openjpa/JPAMessage.java
 Thu Jan 13 12:11:50 2011
@@ -28,20 +28,22 @@ import javax.persistence.Column;
 import javax.persistence.Entity;
 import javax.persistence.FetchType;
 import javax.persistence.Lob;
+import javax.persistence.Table;
 
 import org.apache.james.mailbox.jpa.mail.model.JPAHeader;
 import org.apache.james.mailbox.store.mail.model.Message;
 import org.apache.james.mailbox.store.mail.model.PropertyBuilder;
-import org.apache.james.mailbox.store.streaming.LazySkippingInputStream;
 import org.apache.james.mailbox.store.streaming.StreamUtils;
 
 @Entity(name="Message")
-public class JPAMessage extends AbstractJPAMessage{
-
+@Table(name="JAMES_MAIL")
+public class JPAMessage extends AbstractJPAMessage {
 
     /** 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(length=1048576000)  
@Lob private byte[] content;
+    @Basic(optional = false, fetch = FetchType.LAZY)
+    @Column(name = "MAIL_BYTES", length = 1048576000)
+    @Lob private byte[] content;
 
     @Deprecated
     public JPAMessage() {}

Modified: 
james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/openjpa/JPAStreamingMailboxMembership.java
URL: 
http://svn.apache.org/viewvc/james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/openjpa/JPAStreamingMailboxMembership.java?rev=1058528&r1=1058527&r2=1058528&view=diff
==============================================================================
--- 
james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/openjpa/JPAStreamingMailboxMembership.java
 (original)
+++ 
james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/openjpa/JPAStreamingMailboxMembership.java
 Thu Jan 13 12:11:50 2011
@@ -25,23 +25,28 @@ import java.util.List;
 
 import javax.mail.Flags;
 import javax.persistence.CascadeType;
+import javax.persistence.Column;
 import javax.persistence.Entity;
 import javax.persistence.FetchType;
 import javax.persistence.ManyToOne;
+import javax.persistence.Table;
 
 import org.apache.james.mailbox.MailboxException;
 import org.apache.james.mailbox.jpa.mail.model.JPAHeader;
+import org.apache.james.mailbox.jpa.mail.model.JPAMailbox;
+import org.apache.james.mailbox.store.mail.model.Mailbox;
 import org.apache.james.mailbox.store.mail.model.MailboxMembership;
 import org.apache.james.mailbox.store.mail.model.Message;
 import org.apache.james.mailbox.store.mail.model.PropertyBuilder;
 
 @Entity(name="Membership")
-public class JPAStreamingMailboxMembership extends 
AbstractJPAMailboxMembership{
-
+@Table(name="JAMES_MAILBOX_MEMBERSHIP")
+public class JPAStreamingMailboxMembership extends 
AbstractJPAMailboxMembership {
 
     /** The value for the body field. Lazy loaded */
-    @ManyToOne(cascade = CascadeType.ALL, fetch=FetchType.LAZY) private 
JPAStreamingMessage message;
-  
+    @ManyToOne(cascade = CascadeType.ALL, fetch=FetchType.LAZY)
+    @Column(name = "MAIL_ID", nullable = false)
+    private JPAStreamingMessage message;
     
     /**
      * For enhancement only.
@@ -53,8 +58,6 @@ public class JPAStreamingMailboxMembersh
             InputStream content, int bodyStartOctet, final List<JPAHeader> 
headers, final PropertyBuilder propertyBuilder) throws MailboxException {
         super(mailboxId, uid, internalDate, flags, bodyStartOctet, headers, 
propertyBuilder);  
         this.message = new JPAStreamingMessage(content, size, bodyStartOctet, 
headers, propertyBuilder);
-        
-       
     }
 
     public JPAStreamingMailboxMembership(long mailboxId, long uid,  
MailboxMembership<?> original) throws MailboxException {
@@ -73,6 +76,5 @@ public class JPAStreamingMailboxMembersh
     public Message getMessage() {
         return message;
     }
-    
 
 }

Modified: 
james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/openjpa/JPAStreamingMessage.java
URL: 
http://svn.apache.org/viewvc/james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/openjpa/JPAStreamingMessage.java?rev=1058528&r1=1058527&r2=1058528&view=diff
==============================================================================
--- 
james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/openjpa/JPAStreamingMessage.java
 (original)
+++ 
james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/openjpa/JPAStreamingMessage.java
 Thu Jan 13 12:11:50 2011
@@ -27,6 +27,7 @@ import java.util.List;
 import javax.persistence.Column;
 import javax.persistence.Entity;
 import javax.persistence.FetchType;
+import javax.persistence.Table;
 
 import org.apache.james.mailbox.jpa.mail.model.JPAHeader;
 import org.apache.james.mailbox.store.mail.model.Message;
@@ -46,12 +47,13 @@ import org.apache.openjpa.persistence.Pe
  * TODO: Fix me!
  */
 @Entity(name="Message")
-public class JPAStreamingMessage extends AbstractJPAMessage{
+@Table(name="JAMES_MAIL")
+public class JPAStreamingMessage extends AbstractJPAMessage {
 
-
-       @Persistent(optional=false, fetch=FetchType.LAZY) 
@Column(length=1048576000)  private InputStream content;
+       @Persistent(optional=false, fetch=FetchType.LAZY)
+       @Column(name = "MAIL_BYTES", length=1048576000)
+       private InputStream content;
         
-
     @Deprecated
     public JPAStreamingMessage() {}
 
@@ -74,7 +76,6 @@ public class JPAStreamingMessage extends
     public InputStream getFullContent() throws IOException {
         return content;
     }
-
     
     public InputStream getBodyContent() throws IOException {
         return new LazySkippingInputStream(content, getBodyStartOctet());

Modified: 
james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/user/model/JPASubscription.java
URL: 
http://svn.apache.org/viewvc/james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/user/model/JPASubscription.java?rev=1058528&r1=1058527&r2=1058528&view=diff
==============================================================================
--- 
james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/user/model/JPASubscription.java
 (original)
+++ 
james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/user/model/JPASubscription.java
 Thu Jan 13 12:11:50 2011
@@ -19,6 +19,7 @@
 package org.apache.james.mailbox.jpa.user.model;
 
 import javax.persistence.Basic;
+import javax.persistence.Column;
 import javax.persistence.Entity;
 import javax.persistence.GeneratedValue;
 import javax.persistence.Id;
@@ -32,24 +33,36 @@ import org.apache.james.mailbox.store.us
 /**
  * A subscription to a mailbox by a user.
  */
-@Entity(name="Subscription")
-@Table(uniqueConstraints=@UniqueConstraint(columnNames={"USERNAME", 
"MAILBOX"}))
+@Entity(name = "Subscription")
+@Table(
+    name = "JAMES_SUBSCRIPTION",
+    uniqueConstraints = @UniqueConstraint(columnNames={"USER_NAME", 
"MAILBOX_NAME"})
+)
 @NamedQueries({
-    @NamedQuery(name="findFindMailboxSubscriptionForUser",
-        query="SELECT subscription FROM Subscription subscription WHERE 
subscription.username = :userParam AND subscription.mailbox = :mailboxParam"),  
        
-    @NamedQuery(name="findSubscriptionsForUser",
-        query="SELECT subscription FROM Subscription subscription WHERE 
subscription.username = :userParam")                  
+    @NamedQuery(name = "findFindMailboxSubscriptionForUser",
+        query = "SELECT subscription FROM Subscription subscription WHERE 
subscription.username = :userParam AND subscription.mailbox = :mailboxParam"),  
        
+    @NamedQuery(name = "findSubscriptionsForUser",
+        query = "SELECT subscription FROM Subscription subscription WHERE 
subscription.username = :userParam")                  
 })
 public class JPASubscription implements Subscription {
 
     private static final String TO_STRING_SEPARATOR = "  ";
+    
     /** Primary key */
     @GeneratedValue
-    @Id private long id;
+    @Id 
+    @Column(name = "SUBSCRIPTION_ID", nullable = false)
+    private long id;
+    
     /** Name of the subscribed user */
-    @Basic(optional=false) private String username;
+    @Basic(optional=false)
+    @Column(name = "USER_NAME", nullable = false, length = 100)
+    private String username;
+    
     /** Subscribed mailbox */
-    @Basic(optional=false) private String mailbox;
+    @Basic(optional=false) 
+    @Column(name = "MAILBOX_NAME", nullable = false, length = 100)
+    private String mailbox;
     
     /**
      * Used by JPA
@@ -109,16 +122,13 @@ public class JPASubscription implements 
      *
      * @return output suitable for debugging
      */
-    public String toString()
-    {
+    public String toString() {
         final String result = "Subscription ( "
             + "id = " + this.id + TO_STRING_SEPARATOR
             + "user = " + this.username + TO_STRING_SEPARATOR
             + "mailbox = " + this.mailbox + TO_STRING_SEPARATOR
             + " )";
-    
         return result;
     }
     
-    
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org
For additional commands, e-mail: server-dev-h...@james.apache.org

Reply via email to