com.ibm.commerce.contract.objects

Class AttachmentJDBCHelperBean

  • All Implemented Interfaces:
    java.io.Serializable, javax.ejb.EnterpriseBean, javax.ejb.SessionBean


    public class AttachmentJDBCHelperBean
    extends BaseJDBCHelper
    implements javax.ejb.SessionBean
    Provides methods to perform SQL actions on the database for the Attachment bean.
    See Also:
    Serialized Form
    • Field Detail

      • updateAttachmentContentSQL

        public static final java.lang.String updateAttachmentContentSQL
        SQL to insert the BLOB content column in attachment table given an attachment_id
        See Also:
        Constant Field Values
      • findAttachmentContentSQL

        public static final java.lang.String findAttachmentContentSQL
        SQL to get the BLOB content column from attachment table given an attachment_id where content is not NULL
        See Also:
        Constant Field Values
      • findAttachmentIdsbyOwnerSQL

        public static final java.lang.String findAttachmentIdsbyOwnerSQL
        SQL to find attachment_id,attachmentURL in attachment table given a member_id (owner)
        See Also:
        Constant Field Values
      • findAttachmentIdsbyTypeSQL

        public static final java.lang.String findAttachmentIdsbyTypeSQL
        SQL to find attachment_id,attachmentURL from attachment table given mimetype
        See Also:
        Constant Field Values
      • findAttachmentIdsbyUsageSQL

        public static final java.lang.String findAttachmentIdsbyUsageSQL
        SQL to find attachment_id,attachmentURL from attachment table given attachusg_id
        See Also:
        Constant Field Values
      • findAttachmentIdsbyUploadSQL

        public static final java.lang.String findAttachmentIdsbyUploadSQL
        SQL to find attachment_id,attachmentURL from attachment table given createMethod=1(upload)
        See Also:
        Constant Field Values
      • findAttachmentIdsbySizeSQL

        public static final java.lang.String findAttachmentIdsbySizeSQL
        SQL to find attachment_id,attachmentURL from attachment table given attachment filesize > size
        See Also:
        Constant Field Values
      • findAttachmentSQL

        public static final java.lang.String findAttachmentSQL
        SQL to get the BLOB content column in attachment table given an attachment_id
        See Also:
        Constant Field Values
      • emptyAttachmentContentSQL

        public static final java.lang.String emptyAttachmentContentSQL
        SQL to set the BLOB content column in attachment table given an attachment_id
        See Also:
        Constant Field Values
    • Constructor Detail

      • AttachmentJDBCHelperBean

        public AttachmentJDBCHelperBean()
    • Method Detail

      • updateAttachmentContent

        public int updateAttachmentContent(java.lang.Long aAttachmentId,
                                           java.io.InputStream aContent,
                                           int size,
                                           boolean flush)
                                    throws java.sql.SQLException,
                                           javax.naming.NamingException

        Updates the attachment content to insert stream into column CONTENT (which is a Blob) of ATTACHMENT table.

        This method assumes that attachment object has already been created.

        This should be the first time where the blob content is inserted.

        Parameters:
        aAttachmentId - The ID of the attachment.
        aContent - The InputStream data .
        size - The size of the InputStream data.
        flush - The flag indicating whether changes should be committed immediately.
        Returns:
        The number of rows modified.
        Throws:
        javax.naming.NamingException - The javax.naming.NamingException exception.
        java.sql.SQLException - The java.sql.SQLException exception.
        java.rmi.EJBException
      • findAttachmentContentinBLOB

        public java.sql.Blob findAttachmentContentinBLOB(java.lang.Long aContentId,
                                                         boolean flush)
                                                  throws javax.naming.NamingException,
                                                         java.sql.SQLException
        Retrieves the attachment content by the content ID.
        Parameters:
        aContentId - The content ID.
        flush - The flag indicating whether changes should be committed immediately.
        Returns:
        The attachment content.
        Throws:
        javax.naming.NamingException - The javax.naming.NamingException exception.
        java.sql.SQLException - The java.sql.SQLException exception.
      • getBLOBSizeInSchema

        public int getBLOBSizeInSchema(java.lang.Long aContentId)
                                throws javax.naming.NamingException,
                                       java.sql.SQLException
        Retrieves the size of the attachment content blob size in the attachment table for DB2 we use getPrecision() from ResultSetMetaData to get the blob size for oracle, we cannot use getPrecision() from ResultSetMetaData due to an Oracle bug the getPrecision() will return a value larger than an int canhold and a java exception will be thrown for oracle we will return 10000000 which is the out of the box schema blob size (for DB2) If your business logic(oracle) has a dependecy on the size , you may want to implement your own method to retrieve the oracle blob size.
        Parameters:
        aContentId - The content ID.
        Returns:
        The size of the attachment content.
        Throws:
        javax.naming.NamingException - The javax.naming.NamingException exception.
        java.sql.SQLException - The java.sql.SQLException exception.
      • getAttachmentIdsByOwner

        public java.util.Hashtable getAttachmentIdsByOwner(java.lang.Long aOwnerId)
                                                    throws javax.naming.NamingException,
                                                           java.sql.SQLException
        Retrieves the attachment IDs associated with the specified owner.
        Parameters:
        aOwnerId - The owner ID.
        Returns:
        The attachment IDs associated with the owner.
        Throws:
        javax.naming.NamingException - The javax.naming.NamingException exception.
        java.sql.SQLException - The java.sql.SQLException exception.
      • getAttachmentIdsBySize

        public java.util.Hashtable getAttachmentIdsBySize(java.lang.Long aSize)
                                                   throws javax.naming.NamingException,
                                                          java.sql.SQLException
        Retrieves the attachment IDs by size.
        Parameters:
        aSize - The size of the attachment.
        Returns:
        The attachment IDs.
        Throws:
        javax.naming.NamingException - The javax.naming.NamingException exception.
        java.sql.SQLException - The java.sql.SQLException exception.
      • getAttachmentIdsByUpload

        public java.util.Hashtable getAttachmentIdsByUpload()
                                                     throws javax.naming.NamingException,
                                                            java.sql.SQLException
        Retrieves the attachment IDs of attachments created through upload.
        Returns:
        The attachment IDs.
        Throws:
        javax.naming.NamingException - The javax.naming.NamingException exception.
        java.sql.SQLException - The java.sql.SQLException exception.
      • getAttachmentIdsByUsage

        public java.util.Hashtable getAttachmentIdsByUsage(java.lang.String usage)
                                                    throws javax.naming.NamingException,
                                                           java.sql.SQLException
        Retrieves the attachment IDs associated with the specified usage.
        Parameters:
        usage - The usage of the attachment.
        Returns:
        The attachment IDs.
        Throws:
        javax.naming.NamingException - The javax.naming.NamingException exception.
        java.sql.SQLException - The java.sql.SQLException exception.
      • getAttachmentIdsByContentType

        public java.util.Hashtable getAttachmentIdsByContentType(java.lang.String type)
                                                          throws javax.naming.NamingException,
                                                                 java.sql.SQLException
        Retrieves the attachment IDs associated with the specified content type.
        Parameters:
        type - The content type of the attachment.
        Returns:
        The attachment IDs.
        Throws:
        javax.naming.NamingException - The javax.naming.NamingException exception.
        java.sql.SQLException - The java.sql.SQLException exception.
      • getSessionContext

        public javax.ejb.SessionContext getSessionContext()
        See Also:
        com.ibm.commerce.base.helpers.BaseJDBCHelper#getSessionContext()
      • setSessionContext

        public void setSessionContext(javax.ejb.SessionContext ctx)
        Specified by:
        setSessionContext in interface javax.ejb.SessionBean
        See Also:
        SessionBean.setSessionContext(SessionContext)
      • ejbActivate

        public void ejbActivate()
        Specified by:
        ejbActivate in interface javax.ejb.SessionBean
        See Also:
        SessionBean.ejbActivate()
      • ejbCreate

        public void ejbCreate()
        Creates the AttachmentJDBCHelper bean.
      • ejbPassivate

        public void ejbPassivate()
        Specified by:
        ejbPassivate in interface javax.ejb.SessionBean
        See Also:
        SessionBean.ejbPassivate()
      • ejbRemove

        public void ejbRemove()
        Specified by:
        ejbRemove in interface javax.ejb.SessionBean
        See Also:
        SessionBean.ejbRemove()