org.jboss.ejb.plugins.cmp.jdbc.bridge
Class JDBCAbstractCMPFieldBridge

java.lang.Object
  extended byorg.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCAbstractCMPFieldBridge
All Implemented Interfaces:
CMPFieldBridge (src) , FieldBridge (src) , JDBCCMPFieldBridge (src) , JDBCFieldBridge (src)
Direct Known Subclasses:
JDBCCMP1xFieldBridge (src) , JDBCCMP2xFieldBridge (src)

public abstract class JDBCAbstractCMPFieldBridge
extends java.lang.Object
implements JDBCCMPFieldBridge (src)

JDBCAbstractCMPFieldBridge is the default implementation of JDBCCMPFieldBridge. Most of the heavy lifting of this command is handled by JDBCUtil. It is left to subclasses to implement the logic for getting and setting instance values and dirty checking, as this is dependent on the CMP version used. Life-cycle: Tied to the EntityBridge. Multiplicity: One for each entity bean cmp field.


Field Summary
protected  boolean checkDirtyAfterGet
           
protected  byte defaultFlags
           
protected  java.lang.String fieldName
           
protected  int jdbcContextIndex
           
protected  Logger (src) log
           
protected  JDBCStoreManager (src) manager
           
protected  boolean primaryKeyMember
           
protected  boolean readOnly
           
protected  long readTimeOut
           
protected  CMPFieldStateFactory (src) stateFactory
           
protected  int tableIndex
           
 
Constructor Summary
JDBCAbstractCMPFieldBridge(JDBCStoreManager (src)  manager, JDBCCMPFieldMetaData (src)  metadata)
           
JDBCAbstractCMPFieldBridge(JDBCStoreManager (src)  manager, JDBCCMPFieldMetaData (src)  metadata, JDBCType (src)  jdbcType)
           
JDBCAbstractCMPFieldBridge(JDBCStoreManager (src)  manager, java.lang.String fieldName, java.lang.Class fieldType, JDBCType (src)  jdbcType, boolean readOnly, long readTimeOut, java.lang.Class primaryKeyClass, java.lang.reflect.Field primaryKeyField, int jdbcContextIndex, int tableIndex, boolean checkDirtyAfterGet, CMPFieldStateFactory (src)  stateFactory)
           
 
Method Summary
 void addDefaultFlag(byte flag)
          get rid of it later
 byte getDefaultFlags()
          Returns the default field flags.
 int getFieldIndex()
           
 java.lang.String getFieldName()
          Gets the name of this field.
 java.lang.Class getFieldType()
           
 JDBCType (src) getJDBCType()
          Gets the JDBC type of this field.
 JDBCEntityPersistenceStore (src) getManager()
           
 java.lang.Class getPrimaryKeyClass()
           
 java.lang.reflect.Field getPrimaryKeyField()
          Gets the field of the primary key object in which the value of this field is stored.
 java.lang.Object getPrimaryKeyValue(java.lang.Object primaryKey)
          Gets the value of this field in the specified primaryKey object.
 long getReadTimeOut()
           
 int getTableIndex()
          The index of the field among the table fields.
 java.lang.Object getValue(EntityEnterpriseContext (src)  ctx)
          Gets the value of this field for the specified instance context.
 void initInstance(EntityEnterpriseContext (src)  ctx)
          Set CMPFieldValue to Java default value (i.e., 0 or null).
 boolean isCMPField()
           
 boolean isPrimaryKeyMember()
          Is this field a member of the primary key.
 boolean isReadOnly()
          Is this field read only.
 boolean isRelationTableField()
           
 int loadArgumentResults(java.sql.ResultSet rs, int parameterIndex, java.lang.Object[] argumentRef)
          Loads the value of this cmp field from result set into argument referance.
 int loadInstanceResults(java.sql.ResultSet rs, int parameterIndex, EntityEnterpriseContext (src)  ctx)
          Loads the data from result set into the instance associated with the specified context.
 int loadPrimaryKeyResults(java.sql.ResultSet rs, int parameterIndex, java.lang.Object[] pkRef)
          Loads the data from result set into the primary key object.
abstract  void resetPersistenceContext(EntityEnterpriseContext (src)  ctx)
          Resets any persistence data maintained in the context.
 int setArgumentParameters(java.sql.PreparedStatement ps, int parameterIndex, java.lang.Object arg)
          Sets the prepared statement parameters with the data from the object.
protected abstract  void setDirtyAfterGet(EntityEnterpriseContext (src)  ctx)
           
 int setInstanceParameters(java.sql.PreparedStatement ps, int parameterIndex, EntityEnterpriseContext (src)  ctx)
          Sets the prepared statement parameters with the data from the instance associated with the context.
 void setLockingStrategy(LockingStrategy (src)  lockingStrategy)
           
 int setPrimaryKeyParameters(java.sql.PreparedStatement ps, int parameterIndex, java.lang.Object primaryKey)
          Sets the prepared statement parameters with the data from the primary key.
 java.lang.Object setPrimaryKeyValue(java.lang.Object primaryKey, java.lang.Object value)
          Sets the value of this field to the specified value in the specified primaryKey object.
 void setValue(EntityEnterpriseContext (src)  ctx, java.lang.Object value)
          Sets the value of this field for the specified instance context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMPFieldBridge (src)
getLockedValue, lockInstanceValue
 
Methods inherited from interface org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCFieldBridge (src)
getInstanceValue, isDirty, isLoaded, isReadTimedOut, setClean, setInstanceValue
 

Field Detail

log

protected final Logger (src)  log

manager

protected final JDBCStoreManager (src)  manager

fieldName

protected final java.lang.String fieldName

readOnly

protected final boolean readOnly

readTimeOut

protected final long readTimeOut

primaryKeyMember

protected final boolean primaryKeyMember

jdbcContextIndex

protected final int jdbcContextIndex

tableIndex

protected final int tableIndex

stateFactory

protected CMPFieldStateFactory (src)  stateFactory

checkDirtyAfterGet

protected boolean checkDirtyAfterGet

defaultFlags

protected byte defaultFlags
Constructor Detail

JDBCAbstractCMPFieldBridge

public JDBCAbstractCMPFieldBridge(JDBCStoreManager (src)  manager,
                                  JDBCCMPFieldMetaData (src)  metadata)
                           throws DeploymentException (src) 

JDBCAbstractCMPFieldBridge

public JDBCAbstractCMPFieldBridge(JDBCStoreManager (src)  manager,
                                  JDBCCMPFieldMetaData (src)  metadata,
                                  JDBCType (src)  jdbcType)
                           throws DeploymentException (src) 

JDBCAbstractCMPFieldBridge

public JDBCAbstractCMPFieldBridge(JDBCStoreManager (src)  manager,
                                  java.lang.String fieldName,
                                  java.lang.Class fieldType,
                                  JDBCType (src)  jdbcType,
                                  boolean readOnly,
                                  long readTimeOut,
                                  java.lang.Class primaryKeyClass,
                                  java.lang.reflect.Field primaryKeyField,
                                  int jdbcContextIndex,
                                  int tableIndex,
                                  boolean checkDirtyAfterGet,
                                  CMPFieldStateFactory (src)  stateFactory)
Method Detail

getDefaultFlags

public byte getDefaultFlags()
Description copied from interface: JDBCCMPFieldBridge (src)
Returns the default field flags.

Specified by:
getDefaultFlags in interface JDBCCMPFieldBridge (src)

addDefaultFlag

public void addDefaultFlag(byte flag)
get rid of it later

Specified by:
addDefaultFlag in interface JDBCCMPFieldBridge (src)
Parameters:
flag -

getManager

public JDBCEntityPersistenceStore (src)  getManager()
Specified by:
getManager in interface JDBCFieldBridge (src)

getFieldName

public java.lang.String getFieldName()
Description copied from interface: FieldBridge (src)
Gets the name of this field.

Specified by:
getFieldName in interface FieldBridge (src)
Returns:
the name of this field

getJDBCType

public JDBCType (src)  getJDBCType()
Description copied from interface: JDBCFieldBridge (src)
Gets the JDBC type of this field.

Specified by:
getJDBCType in interface JDBCFieldBridge (src)

getFieldType

public java.lang.Class getFieldType()
Specified by:
getFieldType in interface CMPFieldBridge (src)

isPrimaryKeyMember

public boolean isPrimaryKeyMember()
Description copied from interface: JDBCFieldBridge (src)
Is this field a member of the primary key.

Specified by:
isPrimaryKeyMember in interface JDBCFieldBridge (src)
Returns:
true if this field is a member of the primary key

getPrimaryKeyField

public java.lang.reflect.Field getPrimaryKeyField()
Description copied from interface: JDBCCMPFieldBridge (src)
Gets the field of the primary key object in which the value of this field is stored.

Specified by:
getPrimaryKeyField in interface JDBCCMPFieldBridge (src)

isReadOnly

public boolean isReadOnly()
Description copied from interface: JDBCFieldBridge (src)
Is this field read only.

Specified by:
isReadOnly in interface JDBCFieldBridge (src)
Returns:
true if this field is read only

getReadTimeOut

public long getReadTimeOut()

getValue

public java.lang.Object getValue(EntityEnterpriseContext (src)  ctx)
Description copied from interface: FieldBridge (src)
Gets the value of this field for the specified instance context.

Specified by:
getValue in interface FieldBridge (src)
Parameters:
ctx - the context for which this field's value should be fetched
Returns:
the value of this field

setValue

public void setValue(EntityEnterpriseContext (src)  ctx,
                     java.lang.Object value)
Description copied from interface: FieldBridge (src)
Sets the value of this field for the specified instance context.

Specified by:
setValue in interface FieldBridge (src)
Parameters:
ctx - the context for which this field's value should be set
value - the new value of this field

getPrimaryKeyValue

public java.lang.Object getPrimaryKeyValue(java.lang.Object primaryKey)
                                    throws java.lang.IllegalArgumentException
Description copied from interface: JDBCCMPFieldBridge (src)
Gets the value of this field in the specified primaryKey object.

Specified by:
getPrimaryKeyValue in interface JDBCCMPFieldBridge (src)
Parameters:
primaryKey - the primary key object from which this fields value will be extracted
Returns:
the value of this field in the primaryKey object
Throws:
java.lang.IllegalArgumentException

setPrimaryKeyValue

public java.lang.Object setPrimaryKeyValue(java.lang.Object primaryKey,
                                           java.lang.Object value)
                                    throws java.lang.IllegalArgumentException
Description copied from interface: JDBCCMPFieldBridge (src)
Sets the value of this field to the specified value in the specified primaryKey object.

Specified by:
setPrimaryKeyValue in interface JDBCCMPFieldBridge (src)
Parameters:
primaryKey - the primary key object which the value will be inserted
value - the value for field that will be set in the pk
Returns:
the updated primary key object; the actual object may change not just the value
Throws:
java.lang.IllegalArgumentException

resetPersistenceContext

public abstract void resetPersistenceContext(EntityEnterpriseContext (src)  ctx)
Description copied from interface: JDBCFieldBridge (src)
Resets any persistence data maintained in the context.

Specified by:
resetPersistenceContext in interface JDBCFieldBridge (src)

initInstance

public void initInstance(EntityEnterpriseContext (src)  ctx)
Set CMPFieldValue to Java default value (i.e., 0 or null).

Specified by:
initInstance in interface JDBCFieldBridge (src)

setInstanceParameters

public int setInstanceParameters(java.sql.PreparedStatement ps,
                                 int parameterIndex,
                                 EntityEnterpriseContext (src)  ctx)
Description copied from interface: JDBCFieldBridge (src)
Sets the prepared statement parameters with the data from the instance associated with the context.

Specified by:
setInstanceParameters in interface JDBCFieldBridge (src)

setPrimaryKeyParameters

public int setPrimaryKeyParameters(java.sql.PreparedStatement ps,
                                   int parameterIndex,
                                   java.lang.Object primaryKey)
                            throws java.lang.IllegalArgumentException
Description copied from interface: JDBCCMPFieldBridge (src)
Sets the prepared statement parameters with the data from the primary key.

Specified by:
setPrimaryKeyParameters in interface JDBCCMPFieldBridge (src)
Throws:
java.lang.IllegalArgumentException

setArgumentParameters

public int setArgumentParameters(java.sql.PreparedStatement ps,
                                 int parameterIndex,
                                 java.lang.Object arg)
Description copied from interface: JDBCCMPFieldBridge (src)
Sets the prepared statement parameters with the data from the object. The object must be the type of this field.

Specified by:
setArgumentParameters in interface JDBCCMPFieldBridge (src)

loadInstanceResults

public int loadInstanceResults(java.sql.ResultSet rs,
                               int parameterIndex,
                               EntityEnterpriseContext (src)  ctx)
Description copied from interface: JDBCFieldBridge (src)
Loads the data from result set into the instance associated with the specified context.

Specified by:
loadInstanceResults in interface JDBCFieldBridge (src)

loadPrimaryKeyResults

public int loadPrimaryKeyResults(java.sql.ResultSet rs,
                                 int parameterIndex,
                                 java.lang.Object[] pkRef)
                          throws java.lang.IllegalArgumentException
Description copied from interface: JDBCCMPFieldBridge (src)
Loads the data from result set into the primary key object.

Specified by:
loadPrimaryKeyResults in interface JDBCCMPFieldBridge (src)
Throws:
java.lang.IllegalArgumentException

loadArgumentResults

public int loadArgumentResults(java.sql.ResultSet rs,
                               int parameterIndex,
                               java.lang.Object[] argumentRef)
                        throws java.lang.IllegalArgumentException
Description copied from interface: JDBCFieldBridge (src)
Loads the value of this cmp field from result set into argument referance.

Specified by:
loadArgumentResults in interface JDBCFieldBridge (src)
Throws:
java.lang.IllegalArgumentException

isRelationTableField

public boolean isRelationTableField()
Specified by:
isRelationTableField in interface JDBCCMPFieldBridge (src)
Returns:
true if the field belongs to a relation table

getFieldIndex

public final int getFieldIndex()

getPrimaryKeyClass

public java.lang.Class getPrimaryKeyClass()

getTableIndex

public int getTableIndex()
Description copied from interface: JDBCCMPFieldBridge (src)
The index of the field among the table fields.

Specified by:
getTableIndex in interface JDBCCMPFieldBridge (src)

setLockingStrategy

public void setLockingStrategy(LockingStrategy (src)  lockingStrategy)
Specified by:
setLockingStrategy in interface JDBCCMPFieldBridge (src)
Parameters:
lockingStrategy - locking strategy assigned to the field

setDirtyAfterGet

protected abstract void setDirtyAfterGet(EntityEnterpriseContext (src)  ctx)

isCMPField

public boolean isCMPField()
Specified by:
isCMPField in interface JDBCFieldBridge (src)