FileDocCategorySizeDatePackage
OneToOneAccessor.javaAPI DocGlassfish v2 API5438Tue May 22 16:54:26 BST 2007oracle.toplink.essentials.internal.ejb.cmp3.metadata.accessors

OneToOneAccessor

public class OneToOneAccessor extends ObjectAccessor
A one to one relationship accessor. A @OneToOne annotation currently is not required to be on the accessible object, that is, a 1-1 can default.
author
Guy Pelletier
since
TopLink EJB 3.0 Reference Implementation

Fields Summary
private OneToOne
m_oneToOne
Constructors Summary
public OneToOneAccessor(MetadataAccessibleObject accessibleObject, ClassAccessor classAccessor)
INTERNAL:

        super(accessibleObject, classAccessor);
        m_oneToOne = getAnnotation(OneToOne.class);
    
Methods Summary
public java.util.ListgetCascadeTypes()
INTERNAL: (Overridden in XMLOneToOneAccessor)

        if (m_oneToOne == null) {
            return new ArrayList<String>();
        } else {
            return getCascadeTypes(m_oneToOne.cascade());
        } 
    
public java.lang.StringgetFetchType()
INTERNAL: (Overridden in XMLOneToOneAccessor)

        return (m_oneToOne == null) ? MetadataConstants.EAGER : m_oneToOne.fetch().name();
    
protected java.lang.StringgetLoggingContext()
INTERNAL: Return the logging context for this accessor.

        return m_logger.ONE_TO_ONE_MAPPING_REFERENCE_CLASS;
    
public java.lang.StringgetMappedBy()
INTERNAL: (Overridden in XMLOneToOneAccessor)

        return (m_oneToOne == null) ? "" : m_oneToOne.mappedBy();
    
public java.lang.ClassgetTargetEntity()
INTERNAL: (Overridden in XMLOneToOneAccessor)

        return (m_oneToOne == null) ? void.class : m_oneToOne.targetEntity();
    
public booleanisOneToOne()
INTERNAL:

        return true;
    
public booleanisOptional()
INTERNAL:

        return (m_oneToOne == null) ? true : m_oneToOne.optional();
    
public voidprocess()
INTERNAL: Process a @OneToOne or one-to-one element into a TopLink OneToOne mapping.

        // Initialize our mapping now with what we found.
        OneToOneMapping mapping = initOneToOneMapping();
        
        if (getMappedBy().equals("")) {
            // Owning side, look for JoinColumns or PrimaryKeyJoinColumns.
            processOwningMappingKeys(mapping);
        } else {	
            // Non-owning side, process the foreign keys from the owner.
            OneToOneMapping ownerMapping = null;
            if (getOwningMapping().isOneToOneMapping()){
            	ownerMapping = (OneToOneMapping)getOwningMapping();
            } else {
            	// If improper mapping encountered, throw an exception.
            	getValidator().throwInvalidMappingEncountered(getJavaClass(), getReferenceClass());
            }

            mapping.setSourceToTargetKeyFields(ownerMapping.getTargetToSourceKeyFields());
            mapping.setTargetToSourceKeyFields(ownerMapping.getSourceToTargetKeyFields());
        }
        
        // Add the mapping to the descriptor.
        m_descriptor.addMapping(mapping);