FileDocCategorySizeDatePackage
MetadataPrimaryKeyJoinColumns.javaAPI DocGlassfish v2 API5555Tue May 22 16:54:26 BST 2007oracle.toplink.essentials.internal.ejb.cmp3.metadata.columns

MetadataPrimaryKeyJoinColumns

public class MetadataPrimaryKeyJoinColumns extends Object
Object to hold onto join column metadata.
author
Guy Pelletier
since
TopLink EJB 3.0 Reference Implementation

Fields Summary
private String
m_sourceTableName
private String
m_targetTableName
protected List
m_pkJoinColumns
Constructors Summary
public MetadataPrimaryKeyJoinColumns(String sourceTableName, String targetTableName)
INTERNAL:

        m_sourceTableName = sourceTableName;
        m_targetTableName = targetTableName;
        m_pkJoinColumns = new ArrayList<MetadataPrimaryKeyJoinColumn>();
    
public MetadataPrimaryKeyJoinColumns(PrimaryKeyJoinColumn[] primaryKeyJoinColumns, String sourceTableName, String targetTableName)
INTERNAL:

        this(sourceTableName, targetTableName);
        
        // Process the primary key join column array.
        for (PrimaryKeyJoinColumn pkJoinColumn : primaryKeyJoinColumns) {
            m_pkJoinColumns.add(new MetadataPrimaryKeyJoinColumn(pkJoinColumn, sourceTableName, targetTableName));
        }
    
public MetadataPrimaryKeyJoinColumns(PrimaryKeyJoinColumns primaryKeyJoinColumns, PrimaryKeyJoinColumn primaryKeyJoinColumn, String sourceTableName, String targetTableName)
INTERNAL:

        this(sourceTableName, targetTableName);
        
        // Process all the primary key join columns first.
        if (primaryKeyJoinColumns != null) {
            for (PrimaryKeyJoinColumn pkJoinColumn : primaryKeyJoinColumns.value()) {
                m_pkJoinColumns.add(new MetadataPrimaryKeyJoinColumn(pkJoinColumn, sourceTableName, targetTableName));
            }
        }
        
        // Process the single primary key join column second.
        if (primaryKeyJoinColumn != null) {
            m_pkJoinColumns.add(new MetadataPrimaryKeyJoinColumn(primaryKeyJoinColumn, sourceTableName, targetTableName));
        }
    
Methods Summary
public booleanloadedFromXML()
INTERNAL:

        return false;
    
public java.util.Listvalues(oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataDescriptor descriptor)
INTERNAL: This method is called when it is time to process the primary key join columns. So if the user didn't specify any, then we need to default accordingly.

        // If no primary key join columns are specified ...
        if (m_pkJoinColumns.isEmpty()) {
            if (descriptor.hasCompositePrimaryKey()) {
                // Add a default one for each part of the composite primary
                // key. Foreign and primary key to have the same name.
                for (String primaryKeyField : descriptor.getPrimaryKeyFieldNames()) {
                    m_pkJoinColumns.add(new MetadataPrimaryKeyJoinColumn(m_sourceTableName, m_targetTableName, primaryKeyField));
                }
            } else {
                // Add a default one for the single case, not setting any
                // foreign and primary key names. They will default based
                // on which accessor is using them.
                m_pkJoinColumns.add(new MetadataPrimaryKeyJoinColumn(m_sourceTableName, m_targetTableName));
            }
        }
        
        return m_pkJoinColumns;