Examples of IdentifierFactory


Examples of org.jpox.store.mapped.IdentifierFactory

                // TODO Enable instanceof on non-PC fields (currently just return "true")
                return new BooleanLiteral(qs, mapping, true).eq(new BooleanLiteral(qs, mapping, true));
            }

            // Check if the table of the field has a discriminator
            IdentifierFactory idFactory = qs.getStoreManager().getIdentifierFactory();
            DiscriminatorMetaData dismd = table.getDiscriminatorMetaData();
            DiscriminatorMapping discriminatorMapping = (DiscriminatorMapping)table.getDiscriminatorMapping(false);
            if (discriminatorMapping != null)
            {
                // Has a discriminator so do a join to the table of the field and apply a constraint on its discriminator
                LogicSetExpression fieldTblExpr = null;
                if (fieldName == null)
                {
                    // Using THIS so use default table expression
                    fieldTblExpr = qs.getMainTableExpression();
                }
                else
                {
                    // Using field, so our real table will have an identifier of "THIS_{fieldName}" via INNER JOIN
                    String fieldIdentifier = te.getAlias().getIdentifier();
                    fieldIdentifier += '.' + fieldName;
                    DatastoreIdentifier fieldRangeVar = idFactory.newIdentifier(IdentifierFactory.TABLE, fieldIdentifier);
                    fieldTblExpr = qs.getTableExpression(fieldRangeVar);
                    if (fieldTblExpr == null)
                    {
                        fieldTblExpr = qs.newTableExpression(table, fieldRangeVar);
                    }
                    ScalarExpression fieldExpr = table.getIDMapping().newScalarExpression(qs, fieldTblExpr);
                    expr = mapping.newScalarExpression(qs, te);
                    qs.innerJoin(fieldExpr, expr, fieldTblExpr, true, true);
                }

                // Return a constraint on the discriminator for this table to get the right instances
                // This allows all discriminator values for the instanceof class and all of its subclasses
                // DISCRIM = 'baseVal' OR DISCRIM = 'sub1Val' OR DISCRIM = 'sub2Val' ... etc
                BooleanExpression discrExpr =
                    booleanConditionForClassInDiscriminator(qs, instanceofClass.getName(), dismd,
                        discriminatorMapping, fieldTblExpr);
                Iterator subclassIter = qs.getStoreManager().getSubClassesForClass(instanceofClass.getName(),
                    true, clr).iterator();
                while (subclassIter.hasNext())
                {
                    String subCandidateType = (String)subclassIter.next();
                    discrExpr.ior(booleanConditionForClassInDiscriminator(qs, subCandidateType, dismd,
                        discriminatorMapping, fieldTblExpr));
                }
                discrExpr.encloseWithInParentheses();

                return discrExpr;
            }
            else
            {
                // No discriminator so maybe union, or just a SELECT
                // Need to join to the instanceof class (where appropriate)
                // TODO RDBMS-71 Only join on the UNION select that it is applicable to
                if (table instanceof DatastoreClass)
                {
                    DatastoreClass ct = (DatastoreClass)table;
                    if (ct.managesClass(instanceofClass.getName()))
                    {
                        // This type is managed in this table so must be an instance
                        return new BooleanLiteral(qs, mapping, true).eq(new BooleanLiteral(qs, mapping, true));
                    }
                    else
                    {
                        // The instanceof type is not managed here
                        DatastoreClass instanceofTable = qs.getStoreManager().getDatastoreClass(
                            instanceofClass.getName(), clr);
                        String fieldIdentifier = te.getAlias().getIdentifier();
                        if (fieldName == null)
                        {
                            // Using THIS, so our real table will have an identifier of "THIS_INST"
                            fieldIdentifier += ".INST";
                        }
                        else
                        {
                            // Using field, so our real table will have an identifier of "THIS_{fieldName}"
                            fieldIdentifier += '.' + fieldName;
                        }
                        DatastoreIdentifier fieldRangeVar = idFactory.newIdentifier(IdentifierFactory.TABLE, fieldIdentifier);
                        LogicSetExpression fieldTblExpr = qs.newTableExpression(instanceofTable, fieldRangeVar);
                        ScalarExpression fieldExpr = table.getIDMapping().newScalarExpression(qs, te);
                        if (fieldName == null)
                        {
                            expr = instanceofTable.getIDMapping().newScalarExpression(qs, fieldTblExpr);
View Full Code Here

Examples of org.jpox.store.mapped.IdentifierFactory

                colmds[0] = colmd;
            }
        }

        // Generate the column identifier
        IdentifierFactory idFactory = datastoreContainer.getStoreManager().getIdentifierFactory();
        DatastoreIdentifier identifier = null;
        if (colmd.getName() == null)
        {
            // No name specified, so generate the identifier from the field name
            if (roleForField == JavaTypeMapping.MAPPING_FIELD)
            {
                identifier = idFactory.newIdentifier(IdentifierFactory.COLUMN, fmd.getName());
                int i=0;
                while (datastoreContainer.hasDatastoreField(identifier))
                {
                    identifier = idFactory.newIdentifier(IdentifierFactory.COLUMN, fmd.getName() + "_" + i);
                    i++;
                }
            }
            else if (roleForField == JavaTypeMapping.MAPPING_COLLECTION_ELEMENT)
            {
                // Join table collection element
                identifier = ((RDBMSIdentifierFactory)idFactory).newJoinTableFieldIdentifier(fmd, null, null, true, FieldRole.ROLE_COLLECTION_ELEMENT);
            }
            else if (roleForField == JavaTypeMapping.MAPPING_ARRAY_ELEMENT)
            {
                // Join table array element
                identifier = ((RDBMSIdentifierFactory)idFactory).newJoinTableFieldIdentifier(fmd, null, null, true, FieldRole.ROLE_ARRAY_ELEMENT);
            }
            else if (roleForField == JavaTypeMapping.MAPPING_MAP_KEY)
            {
                // Join table map key
                identifier = ((RDBMSIdentifierFactory)idFactory).newJoinTableFieldIdentifier(fmd, null, null, true, FieldRole.ROLE_MAP_KEY);
            }
            else if (roleForField == JavaTypeMapping.MAPPING_MAP_VALUE)
            {
                // Join table map value
                identifier = ((RDBMSIdentifierFactory)idFactory).newJoinTableFieldIdentifier(fmd, null, null, true, FieldRole.ROLE_MAP_VALUE);
            }

            colmd.setName(identifier.getIdentifier());
        }
        else
        {
            // User has specified a name, so try to keep this unmodified
            identifier = idFactory.newDatastoreFieldIdentifier(colmds[datastoreFieldIndex].getName(),
                datastoreContainer.getStoreManager().getOMFContext().getTypeManager().isDefaultEmbeddedType(fmd.getType()),
                FieldRole.ROLE_CUSTOM);
        }

        // Create the column
View Full Code Here

Examples of org.jpox.store.mapped.IdentifierFactory

            // If column specified add one (use any column name specified on field element)
            colmd = new ColumnMetaData(fmd, fmd.getColumn());
            fmd.addColumn(colmd);
        }

        IdentifierFactory idFactory = datastoreContainer.getStoreManager().getIdentifierFactory();
        if (colmd.getName() == null)
        {
            // No name specified, so generate the identifier from the field name
            DatastoreIdentifier identifier = idFactory.newIdentifier(IdentifierFactory.COLUMN, fmd.getName());
            int i=0;
            while (datastoreContainer.hasDatastoreField(identifier))
            {
                identifier = idFactory.newIdentifier(IdentifierFactory.COLUMN, fmd.getName() + "_" + i);
                i++;
            }

            colmd.setName(identifier.getIdentifier());
            col = (Column) datastoreContainer.addDatastoreField(javaType, identifier, mapping, colmd);
        }
        else
        {
            // User has specified a name, so try to keep this unmodified
            col = (Column) datastoreContainer.addDatastoreField(javaType,
                idFactory.newDatastoreFieldIdentifier(colmd.getName(),
                    datastoreContainer.getStoreManager().getOMFContext().getTypeManager().isDefaultEmbeddedType(fmd.getType()),
                    FieldRole.ROLE_CUSTOM),
                mapping, colmd);
        }
View Full Code Here

Examples of org.jpox.store.mapped.IdentifierFactory

                                               JavaTypeMapping mapping,
                                               ColumnMetaData colmd,
                                               DatastoreField reference,
                                               ClassLoaderResolver clr)
    {
        IdentifierFactory idFactory = datastoreContainer.getStoreManager().getIdentifierFactory();
        DatastoreIdentifier identifier = null;
        if (colmd.getName() == null)
        {
            // No name specified, so generate the identifier from the field name
            AbstractMemberMetaData[] relatedMmds = fmd.getRelatedMemberMetaData(clr);
            identifier = ((RDBMSIdentifierFactory)idFactory).newForeignKeyFieldIdentifier(
                relatedMmds != null ? relatedMmds[0] : null,
                fmd, reference.getIdentifier(),
                datastoreContainer.getStoreManager().getOMFContext().getTypeManager().isDefaultEmbeddedType(fmd.getType()),
                FieldRole.ROLE_OWNER);
            colmd.setName(identifier.getIdentifier());
        }
        else
        {
            // User has specified a name, so try to keep this unmodified
            identifier = idFactory.newDatastoreFieldIdentifier(colmd.getName(), false, FieldRole.ROLE_CUSTOM);
        }
        Column col = (Column)datastoreContainer.addDatastoreField(fmd.getType().getName(), identifier, mapping, colmd);

        // Copy the characteristics of the reference column to this one
        reference.copyConfigurationTo(col);
View Full Code Here

Examples of org.jpox.store.mapped.IdentifierFactory

     **/
    public void initialize(ClassLoaderResolver clr)
    {
        assertIsUninitialized();

        IdentifierFactory idFactory = storeMgr.getIdentifierFactory();

        // "SEQUENCE_NAME" column
        sequenceNameMapping = dba.getMapping(String.class, storeMgr);
        Column colSequenceName=(Column) addDatastoreField(String.class.getName(),
            idFactory.newDatastoreFieldIdentifier(sequenceNameColumnName), sequenceNameMapping, null);
        colSequenceName.setAsPrimaryKey();
        colSequenceName.getColumnMetaData().setLength(Integer.valueOf("255"));
        colSequenceName.getColumnMetaData().setJdbcType("VARCHAR");
    getStoreManager().getMappingManager().createDatastoreMapping(sequenceNameMapping, storeMgr, colSequenceName,
            String.class.getName());

        // "NEXT_VAL" column
        nextValMapping = dba.getMapping(Long.class, storeMgr);
        DatastoreField colNextVal=addDatastoreField(Long.class.getName(),
            idFactory.newDatastoreFieldIdentifier(nextValColumnName), nextValMapping, null);
    getStoreManager().getMappingManager().createDatastoreMapping(nextValMapping, storeMgr, colNextVal, Long.class.getName());

        // Set up JDBC statements for supported operations
        insertStmt = "INSERT INTO " + identifier.getFullyQualifiedName(false) + " (" + colSequenceName.getIdentifier() + "," + colNextVal.getIdentifier() +
            ") VALUES (?,?)";
View Full Code Here

Examples of org.jpox.store.mapped.IdentifierFactory

            {
                JPOXLogger.DATASTORE_SCHEMA.info(LOCALISER.msg("058102",
                    "" + numFKs, this));
            }
            i = fkNames.iterator();
            IdentifierFactory idFactory = storeMgr.getIdentifierFactory();
            Statement stmt = conn.createStatement();
            try
            {
                while (i.hasNext())
                {
                    String constraintName = (String) i.next();
                    String stmtText = null;
                    if (drop_using_constraint)
                    {
                        stmtText = "ALTER TABLE " + identifier + " DROP CONSTRAINT " + idFactory.getIdentifierInAdapterCase(constraintName);
                    }
                    else
                    {
                        stmtText = "ALTER TABLE " + identifier + " DROP FOREIGN KEY " + idFactory.getIdentifierInAdapterCase(constraintName);
                    }
                    if (JPOXLogger.DATASTORE_SCHEMA.isDebugEnabled())
                    {
                        JPOXLogger.DATASTORE_SCHEMA.debug(stmtText);
                    }
View Full Code Here

Examples of org.jpox.store.mapped.IdentifierFactory

    {
        Iterator i = actualIndices.iterator();
        if (requiredIdx.getName() != null)
        {
            // Compare the index name since it is defined
            IdentifierFactory idFactory = requiredIdx.getDatastoreContainerObject().getStoreManager().getIdentifierFactory();
            String reqdName = idFactory.getIdentifierInAdapterCase(requiredIdx.getName()); // Allow for user input in incorrect case
            while (i.hasNext())
            {
                Index actualIdx = (Index) i.next();
                String actualName = idFactory.getIdentifierInAdapterCase(actualIdx.getName()); // Allow for DB returning no quotes
                if (actualName.equals(reqdName) &&
                        actualIdx.getDatastoreContainerObject().getIdentifier().toString().equals(requiredIdx.getDatastoreContainerObject().getIdentifier().toString()))
                {
                    // There already is an index of that name for the same table in the actual list so not needed
                    return false;
View Full Code Here

Examples of org.jpox.store.mapped.IdentifierFactory

                        ColumnMetaData[] colmds = fmd.getColumnMetaData();
                        if (colmds != null && colmds.length > 0)
                        {
                            // Apply this set of ColumnMetaData to the existing mapping
                            int colnum = 0;
                            IdentifierFactory idFactory = getStoreManager().getIdentifierFactory();
                            for (int i=0;i<fieldMapping.getNumberOfDatastoreFields();i++)
                            {
                                Column col = (Column)fieldMapping.getDataStoreMapping(i).getDatastoreField();
                                col.setIdentifier(idFactory.newDatastoreFieldIdentifier(colmds[colnum].getName()));
                                col.setMetaData(colmds[colnum]);

                                colnum++;
                                if (colnum == colmds.length)
                                {
View Full Code Here

Examples of org.jpox.store.mapped.IdentifierFactory

                // Create a column with the specified name and jdbc-type
                if (colmd.getJdbcType().equals("VARCHAR") && colmd.getLength() == null)
                {
                    colmd.setLength(getStoreManager().getOMFContext().getPersistenceConfiguration().getIntProperty("org.jpox.rdbms.stringDefaultLength"));
                }
                IdentifierFactory idFactory = getStoreManager().getIdentifierFactory();
                DatastoreIdentifier colIdentifier = idFactory.newIdentifier(IdentifierFactory.COLUMN, colmd.getName());
                Column col = (Column)addDatastoreField(null, colIdentifier, null, colmd);
                TypeInfo typeInfo = dba.getTypeInfo(JDBCUtils.getJDBCTypeForName(colmd.getJdbcType()));
                col.setTypeInfo(typeInfo);

                if (unmappedColumns == null)
View Full Code Here

Examples of org.jpox.store.mapped.IdentifierFactory

                                    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()) ||
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.