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

MetadataJoinColumns

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

Fields Summary
protected List
m_joinColumns
Constructors Summary
public MetadataJoinColumns()
INTERNAL:

        m_joinColumns = new ArrayList<MetadataJoinColumn>();
    
public MetadataJoinColumns(JoinColumns joinColumns, JoinColumn joinColumn)
INTERNAL:

        this();
        
        // Process all the join columns first.
        if (joinColumns != null) {
            for (JoinColumn jColumn : joinColumns.value()) {
                m_joinColumns.add(new MetadataJoinColumn(jColumn));
            }
        }
        
        // Process the single key join column second.
        if (joinColumn != null) {
            m_joinColumns.add(new MetadataJoinColumn(joinColumn));
        }
    
public MetadataJoinColumns(JoinColumn[] joinColumns)
INTERNAL:

        this();
        
        for (JoinColumn joinColumn : joinColumns) {
            m_joinColumns.add(new MetadataJoinColumn(joinColumn));
        }
    
Methods Summary
public booleanloadedFromXML()
INTERNAL:

        return false;
    
public java.util.Listvalues(oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataDescriptor descriptor)
INTERNAL:

        // If no join columns are specified ...
        if (m_joinColumns.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_joinColumns.add(new MetadataJoinColumn(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_joinColumns.add(new MetadataJoinColumn());
            }
        } else {
            // Need to update any join columns that use a foreign key name
            // for the primary key name. E.G. User specifies the renamed id
            // field name from a primary key join column as the primary key in
            // an inheritance subclass.
            for (MetadataJoinColumn joinColumn : m_joinColumns) {
                DatabaseField pkField = joinColumn.getPrimaryKeyField();
                pkField.setName(descriptor.getPrimaryKeyJoinColumnAssociation(pkField.getName()));
            }
        }
        
        return m_joinColumns;