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

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

public abstract class JDBCAbstractCMPFieldBridge
extends Object
implements JDBCCMPFieldBridge

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.

Version:
$Revision: 57209 $

Revisions:

20021023 Steve Coy:

Author:
Dain Sundstrom, Alex Loubyansky, Heiko W.Rupp

Field Summary
protected  boolean checkDirtyAfterGet
           
protected  byte defaultFlags
           
protected  String fieldName
           
protected  int jdbcContextIndex
           
protected  org.jboss.logging.Logger log
           
protected  JDBCStoreManager manager
           
protected  boolean primaryKeyMember
           
protected  boolean readOnly
           
protected  long readTimeOut
           
protected  CMPFieldStateFactory stateFactory
           
protected  int tableIndex
           
 
Constructor Summary
JDBCAbstractCMPFieldBridge(JDBCStoreManager manager, JDBCCMPFieldMetaData metadata)
           
JDBCAbstractCMPFieldBridge(JDBCStoreManager manager, JDBCCMPFieldMetaData metadata, JDBCType jdbcType)
           
JDBCAbstractCMPFieldBridge(JDBCStoreManager manager, String fieldName, Class fieldType, JDBCType jdbcType, boolean readOnly, long readTimeOut, Class primaryKeyClass, Field primaryKeyField, int jdbcContextIndex, int tableIndex, boolean checkDirtyAfterGet, CMPFieldStateFactory stateFactory)
           
 
Method Summary
 void addDefaultFlag(byte flag)
          get rid of it later
 byte getDefaultFlags()
          Returns the default field flags.
 int getFieldIndex()
           
 String getFieldName()
          Gets the name of this field.
 Class getFieldType()
           
 JDBCType getJDBCType()
          Gets the JDBC type of this field.
 JDBCEntityPersistenceStore getManager()
           
 Class getPrimaryKeyClass()
           
 Field getPrimaryKeyField()
          Gets the field of the primary key object in which the value of this field is stored.
 Object getPrimaryKeyValue(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.
 Object getValue(EntityEnterpriseContext ctx)
          Gets the value of this field for the specified instance context.
 void initInstance(EntityEnterpriseContext 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(ResultSet rs, int parameterIndex, Object[] argumentRef)
          Loads the value of this cmp field from result set into argument referance.
 int loadInstanceResults(ResultSet rs, int parameterIndex, EntityEnterpriseContext ctx)
          Loads the data from result set into the instance associated with the specified context.
 int loadPrimaryKeyResults(ResultSet rs, int parameterIndex, Object[] pkRef)
          Loads the data from result set into the primary key object.
abstract  void resetPersistenceContext(EntityEnterpriseContext ctx)
          Resets any persistence data maintained in the context.
 int setArgumentParameters(PreparedStatement ps, int parameterIndex, Object arg)
          Sets the prepared statement parameters with the data from the object.
protected abstract  void setDirtyAfterGet(EntityEnterpriseContext ctx)
           
 int setInstanceParameters(PreparedStatement ps, int parameterIndex, EntityEnterpriseContext ctx)
          Sets the prepared statement parameters with the data from the instance associated with the context.
 void setLockingStrategy(LockingStrategy lockingStrategy)
           
 int setPrimaryKeyParameters(PreparedStatement ps, int parameterIndex, Object primaryKey)
          Sets the prepared statement parameters with the data from the primary key.
 Object setPrimaryKeyValue(Object primaryKey, Object value)
          Sets the value of this field to the specified value in the specified primaryKey object.
 void setValue(EntityEnterpriseContext ctx, 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
getLockedValue, lockInstanceValue
 
Methods inherited from interface org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCFieldBridge
getInstanceValue, isDirty, isLoaded, isReadTimedOut, setClean, setInstanceValue
 

Field Detail

log

protected final org.jboss.logging.Logger log

manager

protected final JDBCStoreManager manager

fieldName

protected final 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 stateFactory

checkDirtyAfterGet

protected boolean checkDirtyAfterGet

defaultFlags

protected byte defaultFlags
Constructor Detail

JDBCAbstractCMPFieldBridge

public JDBCAbstractCMPFieldBridge(JDBCStoreManager manager,
                                  JDBCCMPFieldMetaData metadata)
                           throws org.jboss.deployment.DeploymentException
Throws:
org.jboss.deployment.DeploymentException

JDBCAbstractCMPFieldBridge

public JDBCAbstractCMPFieldBridge(JDBCStoreManager manager,
                                  JDBCCMPFieldMetaData metadata,
                                  JDBCType jdbcType)
                           throws org.jboss.deployment.DeploymentException
Throws:
org.jboss.deployment.DeploymentException

JDBCAbstractCMPFieldBridge

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

getDefaultFlags

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

Specified by:
getDefaultFlags in interface JDBCCMPFieldBridge

addDefaultFlag

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

Specified by:
addDefaultFlag in interface JDBCCMPFieldBridge

getManager

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

getFieldName

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

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

getJDBCType

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

Specified by:
getJDBCType in interface JDBCFieldBridge

getFieldType

public Class getFieldType()
Specified by:
getFieldType in interface CMPFieldBridge

isPrimaryKeyMember

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

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

getPrimaryKeyField

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

Specified by:
getPrimaryKeyField in interface JDBCCMPFieldBridge

isReadOnly

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

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

getReadTimeOut

public long getReadTimeOut()

getValue

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

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

setValue

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

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

getPrimaryKeyValue

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

Specified by:
getPrimaryKeyValue in interface JDBCCMPFieldBridge
Specified by:
getPrimaryKeyValue in interface JDBCFieldBridge
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:
IllegalArgumentException

setPrimaryKeyValue

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

Specified by:
setPrimaryKeyValue in interface JDBCCMPFieldBridge
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:
IllegalArgumentException

resetPersistenceContext

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

Specified by:
resetPersistenceContext in interface JDBCFieldBridge

initInstance

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

Specified by:
initInstance in interface JDBCFieldBridge

setInstanceParameters

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

Specified by:
setInstanceParameters in interface JDBCFieldBridge

setPrimaryKeyParameters

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

Specified by:
setPrimaryKeyParameters in interface JDBCCMPFieldBridge
Throws:
IllegalArgumentException

setArgumentParameters

public int setArgumentParameters(PreparedStatement ps,
                                 int parameterIndex,
                                 Object arg)
Description copied from interface: JDBCCMPFieldBridge
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

loadInstanceResults

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

Specified by:
loadInstanceResults in interface JDBCFieldBridge

loadPrimaryKeyResults

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

Specified by:
loadPrimaryKeyResults in interface JDBCCMPFieldBridge
Throws:
IllegalArgumentException

loadArgumentResults

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

Specified by:
loadArgumentResults in interface JDBCFieldBridge
Throws:
IllegalArgumentException

isRelationTableField

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

getFieldIndex

public final int getFieldIndex()

getPrimaryKeyClass

public Class getPrimaryKeyClass()

getTableIndex

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

Specified by:
getTableIndex in interface JDBCCMPFieldBridge

setLockingStrategy

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

setDirtyAfterGet

protected abstract void setDirtyAfterGet(EntityEnterpriseContext ctx)

isCMPField

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


Copyright © 2002 JBoss Group, LLC. All Rights Reserved.