Package oracle.toplink.essentials.mappings

Examples of oracle.toplink.essentials.mappings.ManyToManyMapping


     * Process a @ManyToMany or many-to-many element into a TopLink MnayToMany
     * mapping.
     */
    public void process() {
        // Create a M-M mapping and process common collection mapping metadata.
        ManyToManyMapping mapping = new ManyToManyMapping();
        process(mapping);

        if (getMappedBy().equals("")) {
            // Processing the owning side of a M-M that is process a join table.
            processJoinTable(getJoinTable(), mapping);
        } else {
            // We are processing the a non-owning side of a M-M. Must set the
            // mapping read-only.
            mapping.setIsReadOnly(true);
           
            // Get the owning mapping from the reference descriptor metadata.
            ManyToManyMapping ownerMapping = null;
            if (getOwningMapping().isManyToManyMapping()){
              ownerMapping = (ManyToManyMapping)getOwningMapping();
            } else {
              // If improper mapping encountered, throw an exception.
              getValidator().throwInvalidMappingEncountered(getJavaClass(), getReferenceClass());
            }

            // Set the relation table name from the owner.
          mapping.setRelationTableName(ownerMapping.getRelationTableQualifiedName());
              
          // Add all the source foreign keys we found on the owner.
          mapping.setSourceKeyFields(ownerMapping.getTargetKeyFields());
          mapping.setSourceRelationKeyFields(ownerMapping.getTargetRelationKeyFields());
             
          // Add all the target foreign keys we found on the owner.
          mapping.setTargetKeyFields(ownerMapping.getSourceKeyFields());
          mapping.setTargetRelationKeyFields(ownerMapping.getSourceRelationKeyFields());
        }

        // Add the mapping to the descriptor.
        m_descriptor.addMapping(mapping);
    }
View Full Code Here


                getValidator().throwUniDirectionalOneToManyHasJoinColumnSpecified(getAttributeName(), getJavaClass());
            }
           
            // Create a M-M mapping and process common collection mapping
            // metadata.
            ManyToManyMapping mapping = new ManyToManyMapping();
            process(mapping);
           
            // Process the @JoinTable.
            processJoinTable(getJoinTable(), mapping);
           
            // Add the mapping to the descriptor.
            m_descriptor.addMapping(mapping);
        } else {
            // Create a 1-M mapping and process common collection mapping
            // metadata.
            OneToManyMapping mapping = new OneToManyMapping();
            process(mapping);
           
            // 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());
            }
               
            Map<DatabaseField, DatabaseField> keys = ownerMapping.getSourceToTargetKeyFields();
            for (DatabaseField fkField : keys.keySet()) {
                mapping.addTargetForeignKeyField(fkField, keys.get(fkField));
            }  
           
            // Add the mapping to the descriptor.
            m_descriptor.addMapping(mapping);
        }
View Full Code Here

TOP

Related Classes of oracle.toplink.essentials.mappings.ManyToManyMapping

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.