Package org.jpox.store.mapped.mapping

Examples of org.jpox.store.mapped.mapping.PersistenceCapableMapping


        if (idMapping != null)
        {
            return idMapping;
        }

        PersistenceCapableMapping mapping = new PersistenceCapableMapping();
        mapping.initialize(getStoreManager().getDatastoreAdapter(),primaryTable.getClassMetaData().getFullClassName());
        if (getIdentityType() == IdentityType.DATASTORE)
        {
            mapping.addJavaTypeMapping(datastoreIDMapping);
        }
        else if (getIdentityType() == IdentityType.APPLICATION)
        {
            for (int i = 0; i < pkMappings.length; i++)
            {
                mapping.addJavaTypeMapping(pkMappings[i]);
            }
        }
        idMapping = mapping;
        return mapping;
    }
View Full Code Here


                    }
                    else
                    {
                        // Unidirectional (element knows nothing about the owner)
                        String ownerClassName = ownerFmd.getAbstractClassMetaData().getFullClassName();
                        JavaTypeMapping fkMapping = new PersistenceCapableMapping();
                        fkMapping.initialize(dba, ownerClassName);
                        JavaTypeMapping fkDiscrimMapping = null;
                        JavaTypeMapping orderMapping = null;
                        boolean duplicate = false;

                        try
                        {
                            // Get the owner id mapping of the "1" end
                            JavaTypeMapping ownerIdMapping = storeMgr.getDatastoreClass(ownerClassName, clr).getIDMapping();
                            ColumnMetaDataContainer colmdContainer = null;
                            if (ownerFmd.hasCollection() || ownerFmd.hasArray())
                            {
                                // 1-N Collection/array
                                colmdContainer = ownerFmd.getElementMetaData();
                            }
                            else if (ownerFmd.hasMap() && ownerFmd.getKeyMetaData() != null && ownerFmd.getKeyMetaData().getMappedBy() != null)
                            {
                                // 1-N Map with key stored in the value
                                colmdContainer = ownerFmd.getValueMetaData();
                            }
                            else if (ownerFmd.hasMap() && ownerFmd.getValueMetaData() != null && ownerFmd.getValueMetaData().getMappedBy() != null)
                            {
                                // 1-N Map with value stored in the key
                                colmdContainer = ownerFmd.getKeyMetaData();
                            }
                            CorrespondentColumnsMapper correspondentColumnsMapping =
                                new CorrespondentColumnsMapper(colmdContainer, ownerIdMapping, true);
                            int countIdFields = ownerIdMapping.getNumberOfDatastoreFields();
                            for (int i=0; i<countIdFields; i++)
                            {
                                DatastoreMapping refDatastoreMapping = ownerIdMapping.getDataStoreMapping(i);
                                JavaTypeMapping mapping = dba.getMapping(refDatastoreMapping.getJavaTypeMapping().getJavaType(), storeMgr);
                                ColumnMetaData colmd = correspondentColumnsMapping.getColumnMetaDataByIdentifier(((Column)refDatastoreMapping.getDatastoreField()).getIdentifier());
                                if (colmd == null)
                                {
                                    throw new JPOXUserException(LOCALISER.msg("057035",
                                        ((Column)refDatastoreMapping.getDatastoreField()).getIdentifier(), toString())).setFatal();
                                }

                                DatastoreIdentifier identifier = null;
                                IdentifierFactory idFactory = storeMgr.getIdentifierFactory();
                                if (colmd.getName() == null || colmd.getName().length() < 1)
                                {
                                    // No user provided name so generate one
                                    identifier = ((RDBMSIdentifierFactory)idFactory).newForeignKeyFieldIdentifier(ownerFmd,
                                        null, refDatastoreMapping.getDatastoreField().getIdentifier(),
                                        storeMgr.getOMFContext().getTypeManager().isDefaultEmbeddedType(mapping.getJavaType()),
                                        FieldRole.ROLE_OWNER);
                                }
                                else
                                {
                                    // User-defined name
                                    identifier = idFactory.newDatastoreFieldIdentifier(colmd.getName());
                                }
                                DatastoreField refColumn = addDatastoreField(mapping.getJavaType().getName(), identifier, mapping, colmd);
                                ((Column)refDatastoreMapping.getDatastoreField()).copyConfigurationTo(refColumn);

                                if (colmd == null || (colmd != null && !colmd.isAllowsNullSet()) ||
                                    (colmd != null && colmd.isAllowsNullSet() && colmd.isAllowsNull()))
                                {
                                    // User either wants it nullable, or havent specified anything, so make it nullable
                                    refColumn.setNullable();
                                }

                                fkMapping.addDataStoreMapping(getStoreManager().getMappingManager().createDatastoreMapping(mapping, storeMgr, refColumn, refDatastoreMapping.getJavaTypeMapping().getJavaType().getName()));
                                ((PersistenceCapableMapping)fkMapping).addJavaTypeMapping(mapping);
                            }
                        }
                        catch (DuplicateColumnNameException dcne)
                        {
View Full Code Here

        if (idMapping != null)
        {
            return;
        }

        final PersistenceCapableMapping mapping = new PersistenceCapableMapping();
        mapping.initialize(getStoreManager().getDatastoreAdapter(), cmd.getFullClassName());
        if (getIdentityType() == IdentityType.DATASTORE)
        {
            mapping.addJavaTypeMapping(datastoreIDMapping);
        }
        else if (getIdentityType() == IdentityType.APPLICATION)
        {
            for (int i = 0; i < pkMappings.length; i++)
            {
                mapping.addJavaTypeMapping(pkMappings[i]);
            }
        }
        else
        {
            // Nothing to do for nondurable since no identity
View Full Code Here

                    return compiledSQL;
                }

                // Generate id column field information for later checking the id is present
                DatastoreClass table = storeMgr.getDatastoreClass(candidateClass.getName(), clr);
                PersistenceCapableMapping idMapping = (PersistenceCapableMapping)table.getIDMapping();
                String[] idColNames = new String[idMapping.getNumberOfDatastoreFields()];
                boolean[] idColMissing = new boolean[idMapping.getNumberOfDatastoreFields()];
                for (int i=0;i<idMapping.getNumberOfDatastoreFields();i++)
                {
                    DatastoreMapping m = idMapping.getDataStoreMapping(i);
                    idColNames[i] = m.getDatastoreField().getIdentifier().toString();
                    idColMissing[i] = true;
                }

                // Generate discriminator/version information for later checking they are present
View Full Code Here

                    candidateClass.getName()).setFatal();
            }

            // Generate id column field information for later checking the id is present
            DatastoreClass table = storeMgr.getDatastoreClass(candidateClass.getName(), clr);
            PersistenceCapableMapping idMapping = (PersistenceCapableMapping)table.getIDMapping();
            String[] idColNames = new String[idMapping.getNumberOfDatastoreFields()];
            boolean[] idColMissing = new boolean[idMapping.getNumberOfDatastoreFields()];
            for (int i=0;i<idMapping.getNumberOfDatastoreFields();i++)
            {
                DatastoreMapping m = idMapping.getDataStoreMapping(i);
                idColNames[i] = m.getDatastoreField().getIdentifier().toString();
                idColMissing[i] = true;
            }

            // Generate discriminator/version information for later checking they are present
View Full Code Here

TOP

Related Classes of org.jpox.store.mapped.mapping.PersistenceCapableMapping

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.