org.jboss.ejb.plugins.cmp.jdbc.metadata
Class JDBCCMPFieldMetaData

java.lang.Object
  extended byorg.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCCMPFieldMetaData

public final class JDBCCMPFieldMetaData
extends java.lang.Object

Imutable class which holds all the information jbosscmp-jdbc needs to know about a CMP field It loads its data from standardjbosscmp-jdbc.xml and jbosscmp-jdbc.xml


Field Summary
static byte CHECK_DIRTY_AFTER_GET_FALSE
           
static byte CHECK_DIRTY_AFTER_GET_NOT_PRESENT
           
static byte CHECK_DIRTY_AFTER_GET_TRUE
           
 
Constructor Summary
JDBCCMPFieldMetaData(JDBCEntityMetaData (src)  entity)
          This constructor is added especially for unknown primary key field
JDBCCMPFieldMetaData(JDBCEntityMetaData (src)  entity, org.w3c.dom.Element element, JDBCCMPFieldMetaData (src)  defaultValues)
          Constructs cmp field meta data with the data contained in the cmp-field xml element from a jbosscmp-jdbc xml file.
JDBCCMPFieldMetaData(JDBCEntityMetaData (src)  entity, org.w3c.dom.Element element, JDBCCMPFieldMetaData (src)  defaultValues, boolean primaryKeyMember, boolean notNull, boolean readOnly, int readTimeOut, boolean relationTableField)
          Constructs cmp field meta data with the data contained in the cmp-field xml element from a jbosscmp-jdbc xml file.
JDBCCMPFieldMetaData(JDBCEntityMetaData (src)  entity, JDBCCMPFieldMetaData (src)  defaultValues)
           
JDBCCMPFieldMetaData(JDBCEntityMetaData (src)  entity, JDBCCMPFieldMetaData (src)  defaultValues, java.lang.String columnName, boolean primaryKeyMember, boolean notNull, boolean readOnly, int readTimeOut, boolean relationTableField)
          Constructs a foreign key or a relation table key field.
JDBCCMPFieldMetaData(JDBCEntityMetaData (src)  entity, java.lang.String fieldName)
          Constructs cmp field meta data for a field on the specified entity with the specified fieldName.
JDBCCMPFieldMetaData(JDBCEntityMetaData (src)  entity, java.lang.String fieldName, java.lang.Class fieldType, java.lang.String columnName, int jdbcType, java.lang.String sqlType)
          Constructs a field that is used as an optimistic lock
 
Method Summary
 boolean equals(java.lang.Object o)
          Compares this JDBCCMPFieldMetaData against the specified object.
 byte getCheckDirtyAfterGet()
           
 java.lang.String getColumnName()
          Gets the column name the property should use or null if the column name is not overriden.
 JDBCEntityMetaData (src) getEntity()
          Gets the entity on which this field is defined
 java.lang.String getFieldName()
          Gets the name of the field.
 java.lang.Class getFieldType()
          Gets the java Class type of this field.
 int getJDBCType()
          Gets the JDBC type the property should use or Integer.MIN_VALUE if not overriden.
 java.lang.reflect.Field getPrimaryKeyField()
          Gets the Field of the primary key object which contains the value of this field.
 java.util.List getPropertyOverrides()
          Gets the property overrides.
 int getReadTimeOut()
          Gets the length of time (ms) that a read valid or -1 if data must always be reread from the database
 java.lang.String getSQLType()
          Gets the SQL type the property should use or null if not overriden.
 java.lang.String getStateFactory()
           
 int hashCode()
          Returns a hashcode for this JDBCCMPFieldMetaData.
 boolean isAutoIncrement()
           
 boolean isIndexed()
          Should an index for this field be generated? Normally this should be false for primary key fields But it seems there are databases that do not automatically put indices on primary keys *sigh*
 boolean isNotNull()
          Should this field allow null values?
 boolean isPrimaryKeyMember()
          Is this field one of the primary key fields?
 boolean isReadOnly()
          Is this field read only.
 boolean isRelationTableField()
           
 boolean isUnknownPkField()
          Is this field an unknown primary key field?
static byte readCheckDirtyAfterGet(org.w3c.dom.Element element)
           
 java.lang.String toString()
          Returns a string describing this JDBCCMPFieldMetaData.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

CHECK_DIRTY_AFTER_GET_TRUE

public static final byte CHECK_DIRTY_AFTER_GET_TRUE
See Also:
Constant Field Values (src)

CHECK_DIRTY_AFTER_GET_FALSE

public static final byte CHECK_DIRTY_AFTER_GET_FALSE
See Also:
Constant Field Values (src)

CHECK_DIRTY_AFTER_GET_NOT_PRESENT

public static final byte CHECK_DIRTY_AFTER_GET_NOT_PRESENT
See Also:
Constant Field Values (src)
Constructor Detail

JDBCCMPFieldMetaData

public JDBCCMPFieldMetaData(JDBCEntityMetaData (src)  entity)
This constructor is added especially for unknown primary key field


JDBCCMPFieldMetaData

public JDBCCMPFieldMetaData(JDBCEntityMetaData (src)  entity,
                            java.lang.String fieldName)
                     throws DeploymentException (src) 
Constructs cmp field meta data for a field on the specified entity with the specified fieldName.

Parameters:
fieldName - name of the field for which the meta data will be loaded
entity - entity on which this field is defined
Throws:
DeploymentException (src) - if data in the entity is inconsistent with field type

JDBCCMPFieldMetaData

public JDBCCMPFieldMetaData(JDBCEntityMetaData (src)  entity,
                            JDBCCMPFieldMetaData (src)  defaultValues)

JDBCCMPFieldMetaData

public JDBCCMPFieldMetaData(JDBCEntityMetaData (src)  entity,
                            org.w3c.dom.Element element,
                            JDBCCMPFieldMetaData (src)  defaultValues)
                     throws DeploymentException (src) 
Constructs cmp field meta data with the data contained in the cmp-field xml element from a jbosscmp-jdbc xml file. Optional values of the xml element that are not present are instead loaded from the defalutValues parameter.

Parameters:
element - the xml Element which contains the metadata about this field
defaultValues - the JDBCCMPFieldMetaData which contains the values for optional elements of the element
Throws:
DeploymentException (src) - if the xml element is not semantically correct

JDBCCMPFieldMetaData

public JDBCCMPFieldMetaData(JDBCEntityMetaData (src)  entity,
                            org.w3c.dom.Element element,
                            JDBCCMPFieldMetaData (src)  defaultValues,
                            boolean primaryKeyMember,
                            boolean notNull,
                            boolean readOnly,
                            int readTimeOut,
                            boolean relationTableField)
                     throws DeploymentException (src) 
Constructs cmp field meta data with the data contained in the cmp-field xml element from a jbosscmp-jdbc xml file. Optional values of the xml element that are not present are instead loaded from the defalutValues parameter. This constructor form is used to create cmp field meta data for use as foreign keys. The primaryKeyMember parameter is very important in this context because a foreign key is not a primary key member but used a pk member as the default value. If we did not have the primary key member parameter this JDBCCMPFieldMetaData would get the value from the defaultValues and be declared a memeber.


JDBCCMPFieldMetaData

public JDBCCMPFieldMetaData(JDBCEntityMetaData (src)  entity,
                            JDBCCMPFieldMetaData (src)  defaultValues,
                            java.lang.String columnName,
                            boolean primaryKeyMember,
                            boolean notNull,
                            boolean readOnly,
                            int readTimeOut,
                            boolean relationTableField)
Constructs a foreign key or a relation table key field.


JDBCCMPFieldMetaData

public JDBCCMPFieldMetaData(JDBCEntityMetaData (src)  entity,
                            java.lang.String fieldName,
                            java.lang.Class fieldType,
                            java.lang.String columnName,
                            int jdbcType,
                            java.lang.String sqlType)
                     throws DeploymentException (src) 
Constructs a field that is used as an optimistic lock

Method Detail

readCheckDirtyAfterGet

public static byte readCheckDirtyAfterGet(org.w3c.dom.Element element)
                                   throws DeploymentException (src) 
Throws:
DeploymentException (src)

getEntity

public JDBCEntityMetaData (src)  getEntity()
Gets the entity on which this field is defined

Returns:
the entity on which this field is defined

getFieldName

public java.lang.String getFieldName()
Gets the name of the field.

Returns:
the name of this field

getFieldType

public java.lang.Class getFieldType()
Gets the java Class type of this field.

Returns:
the Class type of this field

getColumnName

public java.lang.String getColumnName()
Gets the column name the property should use or null if the column name is not overriden.

Returns:
the name to which this field is persisted or null if the column name is not overriden

getJDBCType

public int getJDBCType()
Gets the JDBC type the property should use or Integer.MIN_VALUE if not overriden.

Returns:
the jdbc type of this field

getSQLType

public java.lang.String getSQLType()
Gets the SQL type the property should use or null if not overriden.

Returns:
the sql data type string used in create table statements

getPropertyOverrides

public java.util.List getPropertyOverrides()
Gets the property overrides. Property overrides change the default mapping of Dependent Value Object properties. If there are no property overrides this method returns an empty list.

Returns:
an unmodifiable list of the property overrides.

isReadOnly

public boolean isReadOnly()
Is this field read only. A read only field will never be persisted

Returns:
true if this field is read only

getReadTimeOut

public int getReadTimeOut()
Gets the length of time (ms) that a read valid or -1 if data must always be reread from the database

Returns:
the length of time that data read database is valid, or -1 if data must always be reread from the database

isPrimaryKeyMember

public boolean isPrimaryKeyMember()
Is this field one of the primary key fields?

Returns:
true if this field is one of the primary key fields

isNotNull

public boolean isNotNull()
Should this field allow null values?

Returns:
true if this field will not allow a null value.

isIndexed

public boolean isIndexed()
Should an index for this field be generated? Normally this should be false for primary key fields But it seems there are databases that do not automatically put indices on primary keys *sigh*

Returns:
true if an index should be generated on this field

getPrimaryKeyField

public java.lang.reflect.Field getPrimaryKeyField()
Gets the Field of the primary key object which contains the value of this field. Returns null, if this field is not a member of the primary key, or if the primray key is single valued.

Returns:
the Field of the primary key which contains the value of this field

isUnknownPkField

public boolean isUnknownPkField()
Is this field an unknown primary key field?

Returns:
true if the field is an unknown primary key field

isAutoIncrement

public boolean isAutoIncrement()
Returns:
true if the key is auto incremented by the database

isRelationTableField

public boolean isRelationTableField()

getCheckDirtyAfterGet

public byte getCheckDirtyAfterGet()

getStateFactory

public java.lang.String getStateFactory()

equals

public boolean equals(java.lang.Object o)
Compares this JDBCCMPFieldMetaData against the specified object. Returns true if the objects are the same. Two JDBCCMPFieldMetaData are the same if they both have the same name and are defined on the same entity.

Parameters:
o - the reference object with which to compare
Returns:
true if this object is the same as the object argument; false otherwise

hashCode

public int hashCode()
Returns a hashcode for this JDBCCMPFieldMetaData. The hashcode is computed based on the hashCode of the declaring entity and the hashCode of the fieldName

Returns:
a hash code value for this object

toString

public java.lang.String toString()
Returns a string describing this JDBCCMPFieldMetaData. The exact details of the representation are unspecified and subject to change, but the following may be regarded as typical: "[JDBCCMPFieldMetaData: fieldName=name, [JDBCEntityMetaData: entityName=UserEJB]]"

Returns:
a string representation of the object