com.ibm.commerce.contract.objects
Class AttachmentJDBCHelperBean

java.lang.Object
  |
  +--com.ibm.commerce.base.helpers.BaseJDBCHelper
        |
        +--com.ibm.commerce.contract.objects.AttachmentJDBCHelperBean

public class AttachmentJDBCHelperBean
extends BaseJDBCHelper

Provides methods to perform SQL actions on the database for the Attachment bean.


Field Summary
static java.lang.String emptyAttachmentContentSQL
          SQL to set the BLOB content column in attachment table given an attachment_id
static java.lang.String findAttachmentContentSQL
          SQL to get the BLOB content column from attachment table given an attachment_id where content is not NULL
static java.lang.String findAttachmentIdsbyOwnerSQL
          SQL to find attachment_id,attachmentURL in attachment table given a member_id (owner)
static java.lang.String findAttachmentIdsbySizeSQL
          SQL to find attachment_id,attachmentURL from attachment table given attachment filesize > size
static java.lang.String findAttachmentIdsbyTypeSQL
          SQL to find attachment_id,attachmentURL from attachment table given mimetype
static java.lang.String findAttachmentIdsbyUploadSQL
          SQL to find attachment_id,attachmentURL from attachment table given createMethod=1(upload)
static java.lang.String findAttachmentIdsbyUsageSQL
          SQL to find attachment_id,attachmentURL from attachment table given attachusg_id
static java.lang.String findAttachmentSQL
          SQL to get the BLOB content column in attachment table given an attachment_id
static java.lang.String updateAttachmentContentSQL
          SQL to insert the BLOB content column in attachment table given an attachment_id
 
Fields inherited from class com.ibm.commerce.base.helpers. BaseJDBCHelper
autoFlush, COPYRIGHT, DATASOURCE, dataSourceConfigData, DB_DB2, DB_DB2_390, DB_DB2J, DB_ORACLE, DBTYPE, mySessionCtx
 
Constructor Summary
AttachmentJDBCHelperBean()
           
 
Method Summary
 void ejbActivate()
           
 void ejbCreate()
          Creates the AttachmentJDBCHelper bean.
 void ejbPassivate()
           
 void ejbRemove()
           
 java.sql.Blob findAttachmentContentinBLOB(java.lang.Long aContentId, boolean flush)
          Retrieves the attachment content by the content ID.
 java.util.Hashtable getAttachmentIdsByContentType(java.lang.String type)
          Retrieves the attachment IDs associated with the specified content type.
 java.util.Hashtable getAttachmentIdsByOwner(java.lang.Long aOwnerId)
          Retrieves the attachment IDs associated with the specified owner.
 java.util.Hashtable getAttachmentIdsBySize(java.lang.Long aSize)
          Retrieves the attachment IDs by size.
 java.util.Hashtable getAttachmentIdsByUpload()
          Retrieves the attachment IDs of attachments created through upload.
 java.util.Hashtable getAttachmentIdsByUsage(java.lang.String usage)
          Retrieves the attachment IDs associated with the specified usage.
 int getBLOBSizeInSchema(java.lang.Long aContentId)
          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 retireve the oralce blob size.
 javax.ejb.SessionContext getSessionContext()
          Gets the session context.
 void setSessionContext(javax.ejb.SessionContext ctx)
           
 int updateAttachmentContent(java.lang.Long aAttachmentId, java.io.InputStream aContent, int size, boolean flush)
          Updates the attachment content to insert stream into column CONTENT (which is a Blob) of ATTACHMENT table.
 
Methods inherited from class com.ibm.commerce.base.helpers. BaseJDBCHelper
buildCommaSeparatedWhereClause, closeConnection, convertFirstRowToHashtable, convertResultSetToTable, convertRowFromHashtable, debugInitConnection, executeQuery, executeUpdate, flush, getCallableStatement, getCharacterStreamFromResultSet, getConnection, getDataSource, getPreparedStatement, getPreparedStatement, init, init, makeConnection, useCloudscape, useDB2_390, useDB2, useOracle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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 javax.naming.NamingException,
                                   java.sql.SQLException

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.

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 retireve the oralce 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()
Description copied from class: BaseJDBCHelper
Gets the session context.
Specified by:
getSessionContext in class BaseJDBCHelper
Returns:
the SessionContext
See Also:
BaseJDBCHelper.getSessionContext()

setSessionContext

public void setSessionContext(javax.ejb.SessionContext ctx)
See Also:
javax.ejb.SessionBean#setSessionContext(SessionContext)

ejbActivate

public void ejbActivate()
See Also:
javax.ejb.SessionBean#ejbActivate()

ejbCreate

public void ejbCreate()
               throws javax.ejb.CreateException
Creates the AttachmentJDBCHelper bean.
Throws:
javax.ejb.CreateException - The javax.ejb.CreateException exception.

ejbPassivate

public void ejbPassivate()
See Also:
javax.ejb.SessionBean#ejbPassivate()

ejbRemove

public void ejbRemove()
See Also:
javax.ejb.SessionBean#ejbRemove()