站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > JBoss 4.0.1 sp1 server API Documentation 英文版文档

JDBCCMRFieldBridge (JBoss Server API) - JBoss 4.0.1 sp1 server API Documentation 英文版文档


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

java.lang.Object
  extended byorg.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCAbstractCMRFieldBridge
      extended byorg.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge
All Implemented Interfaces:
CMRFieldBridge, FieldBridge, JDBCFieldBridge

public final class JDBCCMRFieldBridge
extends JDBCAbstractCMRFieldBridge

JDBCCMRFieldBridge a bean relationship. This class only supports relationships between entities managed by a JDBCStoreManager in the same application.

Life-cycle: Tied to the EntityBridge.

Multiplicity: One for each role that entity has.

Version:
$Revision: 1.92 $
Author:
Dain Sundstrom, Alex Loubyansky

Nested Class Summary
static class JDBCCMRFieldBridge.M2MRelationManager
           
static interface JDBCCMRFieldBridge.RelationDataManager
           
 
Constructor Summary
JDBCCMRFieldBridge(JDBCEntityBridge entity, JDBCStoreManager manager, JDBCRelationshipRoleMetaData metadata)
          Creates a cmr field for the entity based on the metadata.
 
Method Summary
 void addRelatedPKsWaitedForMe(EntityEnterpriseContext ctx)
          Establishes relationships with related entities waited for passed in context to be created.
 void addRelatedPKWaitingForMyPK(Object myPK, Object relatedPK)
           
 void addRelation(EntityEnterpriseContext myCtx, Object fk)
          Adds the foreign key to the set of related ids, and updates any foreign key fields.
 boolean allFkFieldsMappedToPkFields()
          Returns true if all FK fields are mapped to PK fields
 void cascadeDelete(EntityEnterpriseContext ctx, List oldValues)
           
 void createRelationLinks(EntityEnterpriseContext myCtx, Object relatedId)
          Creates the relation links between the instance associated with the context and the related instance (just the id is passed in).
 void createRelationLinks(EntityEnterpriseContext myCtx, Object relatedId, boolean updateForeignKey)
           
 void destroyRelationLinks(EntityEnterpriseContext myCtx, Object relatedId)
          Destroys the relation links between the instance associated with the context and the related instance (just the id is passed in).
 void destroyRelationLinks(EntityEnterpriseContext myCtx, Object relatedId, boolean updateValueCollection)
          Destroys the relation links between the instance associated with the context and the related instance (just the id is passed in).
 void destroyRelationLinks(EntityEnterpriseContext myCtx, Object relatedId, boolean updateValueCollection, boolean updateForeignKey)
           
 DataSource getDataSource()
          Gets the datasource of the relation table if relevent.
 JDBCAbstractEntityBridge getEntity()
          Gets bridge for this entity.
 String getFieldName()
          Gets the name of this field.
 JDBCFieldBridge[] getForeignKeyFields()
          Gets the foreign key fields of this entity (i.e., related entities pk fields)
 Object getInstanceValue(EntityEnterpriseContext myCtx)
          Gets the value of the cmr field for the instance associated with the context.
 JDBCStoreManager getJDBCStoreManager()
          Gets the manager of this entity.
 JDBCType getJDBCType()
          Gets the JDBC type of this field.
 JDBCEntityPersistenceStore getManager()
           
 JDBCRelationshipRoleMetaData getMetaData()
          Gets the metadata of the relationship role that this field represents.
 String getQualifiedTableName()
          Gets the name of the relation table if relevent.
 JDBCReadAheadMetaData getReadAhead()
          Gets the read ahead meta data.
 JDBCAbstractCMRFieldBridge getRelatedCMRField()
          The related entity's cmr field for this relationship.
 EntityBridge getRelatedEntity()
          The related entity.
 javax.ejb.EJBLocalObject getRelatedEntityByFK(Object fk)
          Returns related entity's local interface.
 Object getRelatedId(EntityEnterpriseContext myCtx)
          Get the related entity's id.
 Object getRelatedIdFromContext(EntityEnterpriseContext ctx)
          Creates a new instance of related id based on foreign key value in the context.
 LocalProxyFactory getRelatedInvoker()
          The related entity's local container invoker.
 JDBCEntityBridge getRelatedJDBCEntity()
          The related entity.
 Class getRelatedLocalInterface()
          The related entity's local home interface.
 JDBCStoreManager getRelatedManager()
          The related manger.
 JDBCCMRFieldBridge.RelationDataManager getRelationDataManager()
           
 JDBCRelationMetaData getRelationMetaData()
          Gets the relation metadata.
 JDBCFieldBridge[] getTableKeyFields()
          Gets the key fields that this entity maintains in the relation table.
 String getTableName()
           
 Object getValue(EntityEnterpriseContext ctx)
          Gets the value of this field for the specified instance context.
 boolean hasFKFieldsMappedToCMPFields()
           
 boolean hasForeignKey()
          Does this cmr field have foreign keys.
 void initInstance(EntityEnterpriseContext ctx)
          Initialized the foreign key fields.
 boolean invalidateCache(EntityEnterpriseContext ctx)
           
 boolean isBatchCascadeDelete()
           
 boolean isCMPField()
           
 boolean isCollectionValued()
          Is this a collection valued field.
 boolean isDirty(EntityEnterpriseContext ctx)
          This method is never called.
 boolean isForeignKeyValid(Object fk)
          This method is called only for CMR fields with foreign key fields mapped to CMP fields to check the validity of the foreign key value.
 boolean isLoaded(EntityEnterpriseContext ctx)
          Has the data been loaded?
 boolean isPrimaryKeyMember()
          Is this field a member of the primary key.
 boolean isReadOnly()
          Is this field readonly?
 boolean isReadTimedOut(EntityEnterpriseContext ctx)
          Had the read time expired?
 boolean isSingleValued()
          Is this a single valued field.
 void load(EntityEnterpriseContext myCtx, Collection values)
           
 int loadArgumentResults(ResultSet rs, int parameterIndex, Object[] fkRef)
          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.
 boolean removeFromRelations(EntityEnterpriseContext ctx, Object[] oldRelationsRef)
           
 void removeRelatedPKWaitingForMyPK(Object myPK, Object relatedPK)
           
 void removeRelation(EntityEnterpriseContext myCtx, Object fk)
          Removes the foreign key to the set of related ids, and updates any foreign key fields.
 void resetPersistenceContext(EntityEnterpriseContext ctx)
          resets the persistence context of the foreign key fields
 void resolveRelationship()
           
 void scheduleChildrenForBatchCascadeDelete(EntityEnterpriseContext ctx)
          Schedules children for batch cascade delete.
 void scheduleChildrenForCascadeDelete(EntityEnterpriseContext ctx)
          Schedules children for cascade delete.
 void setClean(EntityEnterpriseContext ctx)
          This method is never called.
 void setForeignKey(EntityEnterpriseContext myCtx, Object fk)
          Sets the foreign key field value.
 int setInstanceParameters(PreparedStatement ps, int parameterIndex, EntityEnterpriseContext ctx)
          Sets the prepared statement parameters with the data from the instance associated with the context.
 void setInstanceValue(EntityEnterpriseContext myCtx, Object newValue)
          Sets the value of the cmr field for the instance associated with the context.
 void setValue(EntityEnterpriseContext ctx, Object value)
          Sets new value.
 void start()
          The third phase of deployment.
 String toString()
           
 
Methods inherited from class org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCAbstractCMRFieldBridge
getPrimaryKeyValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JDBCCMRFieldBridge

public JDBCCMRFieldBridge(JDBCEntityBridge entity,
                          JDBCStoreManager manager,
                          JDBCRelationshipRoleMetaData metadata)
                   throws org.jboss.deployment.DeploymentException
Creates a cmr field for the entity based on the metadata.

Method Detail

getRelationDataManager

public JDBCCMRFieldBridge.RelationDataManager getRelationDataManager()

resolveRelationship

public void resolveRelationship()
                         throws org.jboss.deployment.DeploymentException
Throws:
org.jboss.deployment.DeploymentException

start

public void start()
           throws org.jboss.deployment.DeploymentException
The third phase of deployment. The method is called when relationships are already resolved.

Throws:
org.jboss.deployment.DeploymentException

removeFromRelations

public boolean removeFromRelations(EntityEnterpriseContext ctx,
                                   Object[] oldRelationsRef)

cascadeDelete

public void cascadeDelete(EntityEnterpriseContext ctx,
                          List oldValues)
                   throws javax.ejb.RemoveException,
                          RemoteException
Throws:
javax.ejb.RemoveException
RemoteException

isBatchCascadeDelete

public boolean isBatchCascadeDelete()

getJDBCStoreManager

public JDBCStoreManager getJDBCStoreManager()
Gets the manager of this entity.


getEntity

public JDBCAbstractEntityBridge getEntity()
Gets bridge for this entity.

Specified by:
getEntity in class JDBCAbstractCMRFieldBridge

getMetaData

public JDBCRelationshipRoleMetaData getMetaData()
Gets the metadata of the relationship role that this field represents.

Specified by:
getMetaData in class JDBCAbstractCMRFieldBridge

getRelationMetaData

public JDBCRelationMetaData getRelationMetaData()
Gets the relation metadata.


getFieldName

public String getFieldName()
Gets the name of this field.

Returns:
the name of this field

getQualifiedTableName

public String getQualifiedTableName()
Gets the name of the relation table if relevent.

Specified by:
getQualifiedTableName in class JDBCAbstractCMRFieldBridge

getTableName

public String getTableName()
Specified by:
getTableName in class JDBCAbstractCMRFieldBridge

getDataSource

public DataSource getDataSource()
Gets the datasource of the relation table if relevent.


getReadAhead

public JDBCReadAheadMetaData getReadAhead()
Gets the read ahead meta data.


getJDBCType

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


isPrimaryKeyMember

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

Returns:
true if this field is a member of the primary key

hasForeignKey

public boolean hasForeignKey()
Does this cmr field have foreign keys.

Specified by:
hasForeignKey in class JDBCAbstractCMRFieldBridge

allFkFieldsMappedToPkFields

public boolean allFkFieldsMappedToPkFields()
Returns true if all FK fields are mapped to PK fields


isCollectionValued

public boolean isCollectionValued()
Is this a collection valued field.


isSingleValued

public boolean isSingleValued()
Is this a single valued field.


getTableKeyFields

public JDBCFieldBridge[] getTableKeyFields()
Gets the key fields that this entity maintains in the relation table.

Specified by:
getTableKeyFields in class JDBCAbstractCMRFieldBridge

getForeignKeyFields

public JDBCFieldBridge[] getForeignKeyFields()
Gets the foreign key fields of this entity (i.e., related entities pk fields)

Specified by:
getForeignKeyFields in class JDBCAbstractCMRFieldBridge

getRelatedCMRField

public JDBCAbstractCMRFieldBridge getRelatedCMRField()
The related entity's cmr field for this relationship.

Specified by:
getRelatedCMRField in class JDBCAbstractCMRFieldBridge

getRelatedManager

public JDBCStoreManager getRelatedManager()
The related manger.


getRelatedEntity

public EntityBridge getRelatedEntity()
The related entity.


getRelatedJDBCEntity

public JDBCEntityBridge getRelatedJDBCEntity()
The related entity.


getRelatedLocalInterface

public final Class getRelatedLocalInterface()
The related entity's local home interface.


getRelatedInvoker

public final LocalProxyFactory getRelatedInvoker()
The related entity's local container invoker.


isLoaded

public boolean isLoaded(EntityEnterpriseContext ctx)
Description copied from interface: JDBCFieldBridge
Has the data been loaded?

Parameters:
ctx - - entity's context
Returns:
true if entity is loaded, false - otherwise.

addRelatedPKsWaitedForMe

public void addRelatedPKsWaitedForMe(EntityEnterpriseContext ctx)
Establishes relationships with related entities waited for passed in context to be created.

Parameters:
ctx - - entity's context.

isReadOnly

public boolean isReadOnly()
Is this field readonly?

Returns:
true if this field is read only

isReadTimedOut

public boolean isReadTimedOut(EntityEnterpriseContext ctx)
Had the read time expired?


getValue

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

Parameters:
ctx - - entity's context.
Returns:
the value of this field.

setValue

public void setValue(EntityEnterpriseContext ctx,
                     Object value)
Sets new value.

Parameters:
ctx - - entity's context;
value - - new value.

getInstanceValue

public Object getInstanceValue(EntityEnterpriseContext myCtx)
Gets the value of the cmr field for the instance associated with the context.

Parameters:
myCtx - the context for which this field's value should be fetched
Returns:
the value of this field

getRelatedEntityByFK

public javax.ejb.EJBLocalObject getRelatedEntityByFK(Object fk)
Returns related entity's local interface. If there are foreign key fields mapped to CMP fields, existence of related entity is checked with findByPrimaryKey and if, in this case, related instance is not found, null is returned. If foreign key fields mapped to its own columns then existence of related entity is not checked and just its local object is returned.

Parameters:
fk - - foreign key value.
Returns:
related local object instance.

isForeignKeyValid

public boolean isForeignKeyValid(Object fk)
This method is called only for CMR fields with foreign key fields mapped to CMP fields to check the validity of the foreign key value.

Parameters:
fk - the foreign key to check
Returns:
true if there is related entity with the equal primary key

setInstanceValue

public void setInstanceValue(EntityEnterpriseContext myCtx,
                             Object newValue)
Sets the value of the cmr field for the instance associated with the context.

Parameters:
myCtx - the context for which this field's value should be set
newValue - the new value of this field

createRelationLinks

public void createRelationLinks(EntityEnterpriseContext myCtx,
                                Object relatedId)
Creates the relation links between the instance associated with the context and the related instance (just the id is passed in).

This method calls a.addRelation(b) and b.addRelation(a)


createRelationLinks

public void createRelationLinks(EntityEnterpriseContext myCtx,
                                Object relatedId,
                                boolean updateForeignKey)

destroyRelationLinks

public void destroyRelationLinks(EntityEnterpriseContext myCtx,
                                 Object relatedId)
Destroys the relation links between the instance associated with the context and the related instance (just the id is passed in).

This method calls a.removeRelation(b) and b.removeRelation(a)


destroyRelationLinks

public void destroyRelationLinks(EntityEnterpriseContext myCtx,
                                 Object relatedId,
                                 boolean updateValueCollection)
Destroys the relation links between the instance associated with the context and the related instance (just the id is passed in).

This method calls a.removeRelation(b) and b.removeRelation(a)

If updateValueCollection is false, the related id collection is not updated. This form is only used by the RelationSet iterator.


destroyRelationLinks

public void destroyRelationLinks(EntityEnterpriseContext myCtx,
                                 Object relatedId,
                                 boolean updateValueCollection,
                                 boolean updateForeignKey)

scheduleChildrenForCascadeDelete

public void scheduleChildrenForCascadeDelete(EntityEnterpriseContext ctx)
Schedules children for cascade delete.


scheduleChildrenForBatchCascadeDelete

public void scheduleChildrenForBatchCascadeDelete(EntityEnterpriseContext ctx)
Schedules children for batch cascade delete.


getRelatedId

public Object getRelatedId(EntityEnterpriseContext myCtx)
Get the related entity's id. This only works on single valued cmr fields.


getRelatedIdFromContext

public Object getRelatedIdFromContext(EntityEnterpriseContext ctx)
Creates a new instance of related id based on foreign key value in the context.

Parameters:
ctx - - entity's context.
Returns:
related entity's id.

addRelation

public void addRelation(EntityEnterpriseContext myCtx,
                        Object fk)
Adds the foreign key to the set of related ids, and updates any foreign key fields.


removeRelation

public void removeRelation(EntityEnterpriseContext myCtx,
                           Object fk)
Removes the foreign key to the set of related ids, and updates any foreign key fields.


load

public void load(EntityEnterpriseContext myCtx,
                 Collection values)

setForeignKey

public void setForeignKey(EntityEnterpriseContext myCtx,
                          Object fk)
Sets the foreign key field value.


initInstance

public void initInstance(EntityEnterpriseContext ctx)
Initialized the foreign key fields.


resetPersistenceContext

public void resetPersistenceContext(EntityEnterpriseContext ctx)
resets the persistence context of the foreign key fields


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.


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.


loadArgumentResults

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


isDirty

public boolean isDirty(EntityEnterpriseContext ctx)
This method is never called. In case of a CMR with foreign key fields, only the foreign key fields are asked for the dirty state.


invalidateCache

public boolean invalidateCache(EntityEnterpriseContext ctx)

setClean

public void setClean(EntityEnterpriseContext ctx)
This method is never called. In case of a CMR - with foreign key fields, the foreign key fields are cleaned when necessary according to CMP fields' behaviour. - from m:m relationship, added/removed key pairs are cleared in application tx data map on sync.


isCMPField

public boolean isCMPField()

getManager

public JDBCEntityPersistenceStore getManager()

hasFKFieldsMappedToCMPFields

public boolean hasFKFieldsMappedToCMPFields()

addRelatedPKWaitingForMyPK

public void addRelatedPKWaitingForMyPK(Object myPK,
                                       Object relatedPK)

removeRelatedPKWaitingForMyPK

public void removeRelatedPKWaitingForMyPK(Object myPK,
                                          Object relatedPK)

toString

public String toString()


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