Package org.jpox.store.rdbms.query

Examples of org.jpox.store.rdbms.query.DiscriminatorIteratorStatement


        {
            throw new JPOXException("Class "+objectClass.getName()+" is abstract, and a non abstract was expected.").setFatal();
        }

        // Form the query to find which one of these classes has the instance with this id
        DiscriminatorIteratorStatement discrimStmt = new DiscriminatorIteratorStatement(clr, new Class[] {primaryClass}, true, storeMgr, true);

        // Check all instances of this table to see if we have all possible candidates in our "options" list
        DatastoreClass primaryTable = storeMgr.getDatastoreClass(primaryClass.getName(), clr);
        StoreData[] storeData = storeMgr.getStoreDataForDatastoreContainerObject(primaryTable.getIdentifier());
        boolean haveAllCandidates = true;
        for (int i=0;i<storeData.length;i++)
        {
            if (storeData[i] instanceof MappedStoreData)
            {
                ClassTable tbl = (ClassTable)((MappedStoreData)storeData[i]).getDatastoreContainerObject();
                String[] managedClasses = tbl.getManagedClasses();
                for (int j=0;j<managedClasses.length;j++)
                {
                    boolean managedClassFound = false;
                    Iterator optionsIter = schemaDataOptions.iterator();
                    while (optionsIter.hasNext())
                    {
                        StoreData optionData = (StoreData)optionsIter.next();
                        if (optionData.getName().equals(managedClasses[j]))
                        {
                            managedClassFound = true;
                            break;
                        }
                    }
                    if (!managedClassFound)
                    {
                        haveAllCandidates = false;
                        break;
                    }
                }
                if (!haveAllCandidates)
                {
                    break;
                }
            }
        }

        if (haveAllCandidates)
        {
            // We have all possible candidates that are stored in this table so we can omit the restriction on the discriminator
            discrimStmt.setRestrictDiscriminator(false); // Just retrieve the discriminator for this id (accept any possible disc values)
        }

        // Create the statement
        QueryExpression stmt = discrimStmt.getQueryStatement(null);

        // WHERE (object id) = ?
        // We have to create a StateManager here just to map fields from the AppId key object to the table fields.
        // Really the table should have some way of doing this. TODO : Refactor this
        StateManager sm = StateManagerFactory.newStateManagerForHollow(om, objectClass, id);
View Full Code Here


                }
                else
                {
                    candidates = new Class[] {candidateClass};
                }
                query = (new DiscriminatorIteratorStatement(clr,
                    candidates, subclasses, storeMgr, true)).getQueryStatement(candidateAlias);
            }
            else
            {
                // Use a UNION since we need to join across multiple tables
View Full Code Here

                Class[] cls = new Class[clsNames.length];
                for( int i=0; i<clsNames.length; i++)
                {
                    cls[i] = clr.classForName(clsNames[i]);
                }
                stmt = new DiscriminatorIteratorStatement(clr,
                    cls, true, this.storeMgr, true).getQueryStatement(null);
            }
            else
            {
                stmt = new DiscriminatorIteratorStatement(clr, new Class[] {clr.classForName(elementInfo[0].getClassName())},
                    true, this.storeMgr, true).getQueryStatement(null);
            }
            iterateUsingDiscriminator = true;
        }
        else
View Full Code Here

                Class[] cls = new Class[clsNames.length];
                for( int i=0; i<clsNames.length; i++)
                {
                    cls[i] = clr.classForName(clsNames[i]);
                }
                stmt = new DiscriminatorIteratorStatement(clr,
                    cls, true, this.storeMgr, true).getQueryStatement(null);
            }
            else
            {
                stmt = new DiscriminatorIteratorStatement(clr, new Class[] {clr.classForName(elementInfo[0].getClassName())},
                    true, this.storeMgr, true).getQueryStatement(null);
            }
            iterateUsingDiscriminator = true;
        }
        else
View Full Code Here

                        Class[] cls = new Class[clsNames.length];
                        for (int j=0; j<clsNames.length; j++)
                        {
                            cls[j] = clr.classForName(clsNames[j]);
                        }
                        elementStmt = new DiscriminatorIteratorStatement(clr, cls,
                            true, this.storeMgr, true, allowsNull,
                            containerTable, elementMapping, elmIdentifier).getQueryStatement(null);
                    }
                    else
                    {
                        elementStmt = new DiscriminatorIteratorStatement(clr, new Class[] {elementCls},
                            true, this.storeMgr, true, allowsNull,
                            containerTable, elementMapping, elmIdentifier).getQueryStatement(null);
                    }
                    iterateUsingDiscriminator = true;
                }
View Full Code Here

                        Class[] cls = new Class[clsNames.length];
                        for( int j=0; j<clsNames.length; j++)
                        {
                            cls[j] = clr.classForName(clsNames[j]);
                        }
                        elementStmt = new DiscriminatorIteratorStatement(clr, cls,
                            true, this.storeMgr, true, allowsNull,
                            containerTable, elementMapping, elmIdentifier).getQueryStatement(null);
                    }
                    else
                    {
                        elementStmt = new DiscriminatorIteratorStatement(clr, new Class[] {elementCls},
                            true, this.storeMgr, true, allowsNull,
                            containerTable, elementMapping, elmIdentifier).getQueryStatement(null);
                    }
                    iterateUsingDiscriminator = true;
                }
View Full Code Here

                Class[] cls = new Class[clsNames.length];
                for (int j=0; j<clsNames.length; j++)
                {
                    cls[j] = clr.classForName(clsNames[j]);
                }
                stmt = new DiscriminatorIteratorStatement(clr,
                    cls, true, this.storeMgr, true).getQueryStatement(null);
            }
            else
            {
                stmt = new DiscriminatorIteratorStatement(clr, new Class[] {elementCls},
                    true, this.storeMgr, true).getQueryStatement(null);
            }
            iterateUsingDiscriminator = true;

            // Add inner join to the container table
View Full Code Here

                Class[] cls = new Class[clsNames.length];
                for( int i=0; i<clsNames.length; i++)
                {
                    cls[i] = clr.classForName(clsNames[i]);
                }
                stmt = new DiscriminatorIteratorStatement(clr,
                    cls, true, this.storeMgr, true).getQueryStatement(null);
            }
            else
            {
                stmt = new DiscriminatorIteratorStatement(clr, new Class[] {valueCls},
                    true, this.storeMgr, true).getQueryStatement(null);
            }
            iterateUsingDiscriminator = true;
        }
        else
View Full Code Here

                Class[] cls = new Class[clsNames.length];
                for (int j=0; j<clsNames.length; j++)
                {
                    cls[j] = clr.classForName(clsNames[j]);
                }
                stmt = new DiscriminatorIteratorStatement(clr,
                    cls, true, this.storeMgr, true).getQueryStatement(null);
            }
            else
            {
                stmt = new DiscriminatorIteratorStatement(clr, new Class[] {elementCls},
                    true, this.storeMgr, true).getQueryStatement(null);
            }

            iterateUsingDiscriminator = true;
View Full Code Here

                        Class[] cls = new Class[clsNames.length];
                        for( int j=0; j<clsNames.length; j++)
                        {
                            cls[j] = clr.classForName(clsNames[j]);
                        }
                        elementStmt = new DiscriminatorIteratorStatement(clr, cls,
                            true, this.storeMgr, true, allowsNull,
                            containerTable, elementMapping, elmIdentifier).getQueryStatement(null);
                    }
                    else
                    {
                        elementStmt = new DiscriminatorIteratorStatement(clr, new Class[] {elementCls},
                            true, this.storeMgr, true, allowsNull,
                            containerTable, elementMapping, elmIdentifier).getQueryStatement(null);
                    }
                    iterateUsingDiscriminator = true;
                }
View Full Code Here

TOP

Related Classes of org.jpox.store.rdbms.query.DiscriminatorIteratorStatement

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.