Package org.jpox.store.mapped

Examples of org.jpox.store.mapped.StatementExpressionIndex


        for (int i=0; i<pkFieldNumbers.length; ++i)
        {
            AbstractMemberMetaData fmd = cmd.getMetaDataForManagedMemberAtAbsolutePosition(pkFieldNumbers[i]);
            JavaTypeMapping m = datastoreClass.getFieldMapping(fmd);
            statementExpressionIndex[fmd.getAbsoluteFieldNumber()] = new StatementExpressionIndex();
            statementExpressionIndex[fmd.getAbsoluteFieldNumber()].setMapping(m);
            int expressionsIndex[] = new int[m.getNumberOfDatastoreFields()];
            for (int j = 0; j < expressionsIndex.length; j++)
            {
                expressionsIndex[j] = param[paramIndex++];
View Full Code Here


                {
                    throw new JPOXException(LOCALISER_RDBMS.msg("053001",
                        m, candidateClass.getName())).setFatal();
                }
               
        statementExpressionIndex[i] = new StatementExpressionIndex();
        statementExpressionIndex[i].setMapping(m);
                fn[prefetchFieldCount++] = i;
            }
        }
View Full Code Here

                    JavaTypeMapping m = tables[0].getFieldMapping(cmd.getMetaDataForManagedMemberAtAbsolutePosition(prefetchFieldNumbers[i]));
                    if (m != null) // field is not stored in the table, e.g List, Set, etc or is transactional
                    {
                        if (m.includeInFetchStatement() && !(m instanceof AbstractContainerMapping))
                        {
                            statementExpressionIndex[prefetchFieldNumbers[i]] = new StatementExpressionIndex();
                            statementExpressionIndex[prefetchFieldNumbers[i]].setMapping(m);
                            statementExpressionIndex[prefetchFieldNumbers[i]].setExpressionIndex(stmt.selectField(fieldName, "APP_ID", true));
                        }
                    }
                }
            }
            // TODO Select fetch plan fields also ? This should be done for all fields that are in *all* subclass tables
        }
        else
        {
            // TODO When we have all possible candidates in single table and using discriminator
            // we should really select all fields here to save doing the retrieve of the other fields later.
            // Currently we only retrieve the fetch-plan/DFG fields for the base candidate class

            if (useFetchPlan)
            {
                // Select all fields in the FetchPlan
                // TODO This only utilises the first table. What if we have multiple ?
                AbstractClassMetaData cmd = storeMgr.getOMFContext().getMetaDataManager().getMetaDataForClass(getCandidateClass(), stmt.getClassLoaderResolver());
                getFetchPlan().manageFetchPlanForClass(cmd);
                FetchPlanForClass fpc = getFetchPlan().getFetchPlanForClass(cmd);
                int fieldNumbers[] = fpc.getFieldsInActualFetchPlan();
                int prefetchFieldCount = 0;
                int fieldCount = cmd.getNoOfInheritedManagedMembers() + cmd.getNoOfManagedMembers();
               
                int fn[] = new int[fieldNumbers.length];
                statementExpressionIndex = new StatementExpressionIndex[fieldCount];
                for (int i = 0; i < fieldNumbers.length; ++i)
                {
                    JavaTypeMapping m = tables[0].getFieldMapping(cmd.getMetaDataForManagedMemberAtAbsolutePosition(fieldNumbers[i]));
                    if (m != null)
                    {
                        // omit fields not stored in the table, e.g. List, Set, etc or transactional
                        if (m.includeInFetchStatement() && !(m instanceof AbstractContainerMapping))
                        {
                            statementExpressionIndex[fieldNumbers[i]] = new StatementExpressionIndex();
                            statementExpressionIndex[fieldNumbers[i]].setMapping(m);
                            fn[prefetchFieldCount++] = fieldNumbers[i];
                        }
                    }
                }
               
                prefetchFieldNumbers = new int[prefetchFieldCount];
                System.arraycopy(fn, 0, prefetchFieldNumbers, 0, prefetchFieldCount);
               
                // select the fetch-plan fields to be fetched from the database
                if (stmt.getTableExpression(elmIdentifier) != null)
                {
                    Mappings.selectMapping(stmt, elmIdentifier, statementExpressionIndex);
                }
                else
                {
                    Mappings.selectMapping(stmt, statementExpressionIndex);
                }
            }
            else
            {
                // if no fetchplan is used and is application identity, select only PK fields
                AbstractClassMetaData cmd = storeMgr.getOMFContext().getMetaDataManager().getMetaDataForClass(getCandidateClass(),stmt.getClassLoaderResolver());
                if (cmd.getIdentityType() == IdentityType.APPLICATION)
                {
                    prefetchFieldNumbers = new int[cmd.getPKMemberPositions().length];
                    int fieldCount = cmd.getNoOfInheritedManagedMembers() + cmd.getNoOfManagedMembers();
                    statementExpressionIndex = new StatementExpressionIndex[fieldCount];
                    for (int i = 0; i < prefetchFieldNumbers.length; ++i)
                    {
                        prefetchFieldNumbers[i] = cmd.getPKMemberPositions()[i];
                        JavaTypeMapping m = tables[0].getFieldMapping(cmd.getMetaDataForManagedMemberAtAbsolutePosition(prefetchFieldNumbers[i]));
                        if (m != null) // field is not stored in the table, e.g List, Set, etc or is transactional
                        {
                            if (m.includeInFetchStatement() && !(m instanceof AbstractContainerMapping))
                            {
                                statementExpressionIndex[prefetchFieldNumbers[i]] = new StatementExpressionIndex();
                                statementExpressionIndex[prefetchFieldNumbers[i]].setMapping(m);
                            }
                        }
                    }
                    // following the actual fetch plan, we select the fields to be fetched from the database
View Full Code Here

            JavaTypeMapping fieldMapping = embeddedMapping.getJavaTypeMapping(i);
            int absFieldNum = emd.getAbsolutePositionOfMember(fieldMapping.getFieldMetaData().getName());
            elementFieldNumbers[i] = absFieldNum;
            if (fieldMapping != null)
            {
                statementExpressionIndex[absFieldNum] = new StatementExpressionIndex();
                statementExpressionIndex[absFieldNum].setMapping(fieldMapping);
                int[] jdbcParamPositions = new int[fieldMapping.getNumberOfDatastoreFields()];
                for (int j=0;j<fieldMapping.getNumberOfDatastoreFields();j++)
                {
                    jdbcParamPositions[j] = jdbcPosition++;
View Full Code Here

                        JavaTypeMapping m = elementInfo[0].getDatastoreClass().getFieldMapping(fmd);
                        if (m != null) // Field is not a Collection, List, Map, etc so has a datastore mapping
                        {
                            if (m.includeInFetchStatement() && !(m instanceof AbstractContainerMapping))
                            {
                                statementExpressionIndex[fieldNumbers[i]] = new StatementExpressionIndex();
                                statementExpressionIndex[fieldNumbers[i]].setMapping(m);
                                fn[prefetchFieldCount++] = fieldNumbers[i];
                            }
                        }
                    }
                }
               
                prefetchFieldNumbers = new int[prefetchFieldCount];
                System.arraycopy(fn, 0, prefetchFieldNumbers, 0, prefetchFieldCount);
            }
            else
            {
                // if no fetchplan is used and is application identity, select only PK fields
                if (emd.getIdentityType() == IdentityType.APPLICATION)
                {
                    prefetchFieldNumbers = new int[emd.getPKMemberPositions().length];
                    int fieldCount = emd.getNoOfInheritedManagedMembers() + emd.getNoOfManagedMembers();
                    statementExpressionIndex = new StatementExpressionIndex[fieldCount];
                    for (int i = 0; i < prefetchFieldNumbers.length; ++i)
                    {
                        prefetchFieldNumbers[i] = emd.getPKMemberPositions()[i];
                        AbstractMemberMetaData fmd = emd.getMetaDataForManagedMemberAtAbsolutePosition(prefetchFieldNumbers[i]);
                        if (fmd.getPersistenceModifier() == FieldPersistenceModifier.PERSISTENT)
                        {
                            JavaTypeMapping m = elementInfo[0].getDatastoreClass().getFieldMapping(fmd);
                            if (m != null) // Field is not a Collection, List, Map, etc so has a datastore mapping
                            {
                                if (m.includeInFetchStatement() && !(m instanceof AbstractContainerMapping))
                                {
                                    statementExpressionIndex[prefetchFieldNumbers[i]] = new StatementExpressionIndex();
                                    statementExpressionIndex[prefetchFieldNumbers[i]].setMapping(m);
                                }
                            }
                        }
                    }
View Full Code Here

     * @param stmtExprIndexList the List of StatementExpressionIndex
     * @param expr1 the ScalarExpression
     */
    private void selectLiteralExpression(QueryExpression stmt, List stmtExprIndexList, ScalarExpression expr1)
    {
        StatementExpressionIndex stmtExprIndex = new StatementExpressionIndex();
        //when we have literal values, we don't put the literal in the SQL, but we put the identity columns, so it returns the correct
        //we IGNORE the literal values in the query, and use the literal mapping when the result set is returned
        //here, we just make sure that some columns are added to the SELECT by adding the ID mapping
        AbstractClassMetaData cmd = storeMgr.getOMFContext().getMetaDataManager().getMetaDataForClass(candidateClass, stmt.getClassLoaderResolver());
        if (cmd.getIdentityType() == IdentityType.DATASTORE)
        {
            stmt.select(storeMgr.getDatastoreClass(candidateClass.getName(), clr).getDataStoreObjectIdMapping(), true);
            stmtExprIndex.setMapping(expr1.getMapping());
        }
        else if (cmd.getIdentityType() == IdentityType.APPLICATION)
        {
            int[] prefetchFieldNumbers = new int[cmd.getPKMemberPositions().length];
            for (int j = 0; j < prefetchFieldNumbers.length; ++j)
            {
                prefetchFieldNumbers[j] = cmd.getPKMemberPositions()[j];
                JavaTypeMapping m = storeMgr.getDatastoreClass(candidateClass.getName(), clr).getFieldMapping(
                    cmd.getMetaDataForManagedMemberAtAbsolutePosition(prefetchFieldNumbers[j]));
                if (m != null) // field is not stored in the table, e.g List, Set, etc or is transactional
                {
                    if (m.includeInFetchStatement() && !(m instanceof AbstractContainerMapping))
                    {
                        stmt.select(m, true);
                    }
                }
            }
            stmtExprIndex.setMapping(expr1.getMapping());
        }
        if (expr1.getMapping() instanceof SingleFieldMapping)
        {
            if (expr1 instanceof Literal)
            {
                stmtExprIndex.setMapping(new ResultLiteralJavaTypeMapping(expr1.getMapping(), ((Literal) expr1).getValue()));
            }
        }
        stmtExprIndexList.add(stmtExprIndex);
    }
View Full Code Here

        {
            selectNewObjectExpression(stmt, stmtExprIndexList, expr1);
        }
        else
        {
            StatementExpressionIndex stmtExprIndex = new StatementExpressionIndex();
            int[] exprIndex = null;

            ScalarExpression[] expr = expr1.getExpressionList().toArray();
            if (expr.length > 0)
            {
                // Expression made up of sub-expressions
                exprIndex = new int[expr.length];
                for (int j=0; j<expr.length; j++)
                {
                    exprIndex[j] = stmt.selectScalarExpression(expr[j], true);
                }
            }
            else
            {
                exprIndex = new int[1];
                exprIndex[0] = stmt.selectScalarExpression(expr1, true);
            }
            stmtExprIndex.setExpressionIndex(exprIndex);
            stmtExprIndex.setMapping(expr1.getMapping());
            if (expr1.getAlias() != null)
            {
                stmtExprIndex.setColumnName(expr1.getAlias());
            }
            stmtExprIndexList.add(stmtExprIndex);
        }
    }
View Full Code Here

            JavaTypeMapping fieldMapping = embeddedMapping.getJavaTypeMapping(i);
            int absFieldNum = kmd.getAbsolutePositionOfMember(fieldMapping.getFieldMetaData().getName());
            elementFieldNumbers[i] = absFieldNum;
            if (fieldMapping != null)
            {
                statementExpressionIndex[absFieldNum] = new StatementExpressionIndex();
                statementExpressionIndex[absFieldNum].setMapping(fieldMapping);
                int[] jdbcParamPositions = new int[fieldMapping.getNumberOfDatastoreFields()];
                for (int j=0;j<fieldMapping.getNumberOfDatastoreFields();j++)
                {
                    jdbcParamPositions[j] = jdbcPosition++;
View Full Code Here

            JavaTypeMapping fieldMapping = embeddedMapping.getJavaTypeMapping(i);
            int absFieldNum = vmd.getAbsolutePositionOfMember(fieldMapping.getFieldMetaData().getName());
            elementFieldNumbers[i] = absFieldNum;
            if (fieldMapping != null)
            {
                statementExpressionIndex[absFieldNum] = new StatementExpressionIndex();
                statementExpressionIndex[absFieldNum].setMapping(fieldMapping);
                int[] jdbcParamPositions = new int[fieldMapping.getNumberOfDatastoreFields()];
                for (int j=0;j<fieldMapping.getNumberOfDatastoreFields();j++)
                {
                    jdbcParamPositions[j] = jdbcPosition++;
View Full Code Here

                    JavaTypeMapping m = valueTable.getFieldMapping(vmd.getMetaDataForManagedMemberAtAbsolutePosition(fieldNumbers[i]));
                    if (m != null)
                    {
                        if (m.includeInFetchStatement() && !(m instanceof AbstractContainerMapping))
                        {
                            statementExpressionIndex[fieldNumbers[i]] = new StatementExpressionIndex();
                            statementExpressionIndex[fieldNumbers[i]].setMapping(m);
                            fn[prefetchFieldCount++] = fieldNumbers[i];
                        }
                    }
                }
               
                prefetchFieldNumbers = new int[prefetchFieldCount];
                System.arraycopy(fn, 0, prefetchFieldNumbers, 0, prefetchFieldCount);
            }
            else
            {
                AbstractClassMetaData cmd = vmd;
                if (cmd.getIdentityType() == IdentityType.APPLICATION)
                {
                    prefetchFieldNumbers = new int[cmd.getPKMemberPositions().length];
                    int fieldCount = cmd.getNoOfInheritedManagedMembers() + cmd.getNoOfManagedMembers();
                    statementExpressionIndex = new StatementExpressionIndex[fieldCount];
                    for (int i = 0; i < prefetchFieldNumbers.length; ++i)
                    {
                        prefetchFieldNumbers[i] = cmd.getPKMemberPositions()[i];
                        JavaTypeMapping m = valueTable.getFieldMapping(cmd.getMetaDataForManagedMemberAtAbsolutePosition(prefetchFieldNumbers[i]));
                        if (m != null) // field is not stored in the table, e.g List, Set, etc or is transactional
                        {
                            if (m.includeInFetchStatement() && !(m instanceof AbstractContainerMapping))
                            {
                                statementExpressionIndex[prefetchFieldNumbers[i]] = new StatementExpressionIndex();
                                statementExpressionIndex[prefetchFieldNumbers[i]].setMapping(m);
                            }
                        }
                    }
                }
View Full Code Here

TOP

Related Classes of org.jpox.store.mapped.StatementExpressionIndex

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.