Package org.jpox.exceptions

Examples of org.jpox.exceptions.JPOXUserException


    public Object executeWithArray(Object[] parameterValues)
    {
        if (om == null)
        {
            // Is checked at construction, but could have been deserialised (and serialised have no manager)
            throw new JPOXUserException(LOCALISER.msg("021017"));
        }

        // Compile the explicit parameters
        QueryCompiler c = new QueryCompiler(this, getParsedImports(), null);
        c.compile(QueryCompiler.COMPILE_EXPLICIT_PARAMETERS);
View Full Code Here


    public Object executeWithMap(Map parameters)
    {
        if (om == null)
        {
            // Is checked at construction, but could have been deserialised (and serialised have no manager)
            throw new JPOXUserException(LOCALISER.msg("021017"));
        }
        if (om.isClosed())
        {
            // Throw exception if query is closed (e.g JDO2 [14.6.1])
            throw new JPOXUserException(LOCALISER.msg("021013")).setFatal();
        }
        if (!om.getTransaction().isActive() && !om.getTransaction().getNontransactionalRead())
        {
            throw new TransactionNotReadableException();
        }
View Full Code Here

    public long deletePersistentAll(Map parameters)
    {
        if (om.isClosed())
        {
            // Throw exception if query is closed (e.g JDO2 [14.6.1])
            throw new JPOXUserException(LOCALISER.msg("021013")).setFatal();
        }
        if (!om.getTransaction().isActive() && !om.getTransaction().getNontransactionalWrite())
        {
            // tx not active and not allowing non-tx write
            throw new TransactionNotActiveException();
        }

        // Compile the "query" for execution
        compileInternal(true, parameters);

        // Check for specification of any illegal attributes
        if (result != null)
        {
            throw new JPOXUserException(LOCALISER.msg("021029"));
        }
        if (resultClass != null)
        {
            throw new JPOXUserException(LOCALISER.msg("021030"));
        }
        if (resultClassName != null)
        {
            throw new JPOXUserException(LOCALISER.msg("021030"));
        }
        if (ordering != null)
        {
            throw new JPOXUserException(LOCALISER.msg("021027"));
        }
        if (grouping != null)
        {
            throw new JPOXUserException(LOCALISER.msg("021028"));
        }
        if (range != null)
        {
            throw new JPOXUserException(LOCALISER.msg("021031"));
        }
        if (fromInclNo >= 0 && toExclNo >= 0 && (fromInclNo != 0 || toExclNo != Long.MAX_VALUE))
        {
            throw new JPOXUserException(LOCALISER.msg("021031"));
        }

        long qr = performDeletePersistentAll(parameters);

        return qr;
View Full Code Here

                        table = qs.getStoreManager().getDatastoreClass(cmds[0].getFullClassName(), clr);
                    }
                    else
                    {
                        // No subclasses with tables to join to, so throw a user error
                        throw new JPOXUserException(LOCALISER.msg("037005",
                            mapping.getFieldMetaData().getFullFieldName()));
                    }
                }
                else
                {
View Full Code Here

                            table = qs.getStoreManager().getDatastoreClass(cmds[0].getFullClassName(), clr);
                        }
                        else
                        {
                            // No subclasses with tables to join to, so throw a user error
                            throw new JPOXUserException(LOCALISER.msg("037005",
                                mapping.getFieldMetaData().getFullFieldName()));
                        }
                    }
                    else
                    {
                        // Class of the field will have its own table
                        table = qs.getStoreManager().getDatastoreClass(mapping.getType(), clr);
                    }
                }
                else
                {
                    table = qs.getStoreManager().getDatastoreClass(mapping.getType(), clr);
                }
            }
            catch (ClassNotPersistenceCapableException cnpce)
            {
                // Field is not PersistenceCapable
                // 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);
                        }
                        else
                        {
                            expr = mapping.newScalarExpression(qs, fieldTblExpr);
                        }
                        qs.innerJoin(fieldExpr, expr, fieldTblExpr, true, true);
                        return new BooleanLiteral(qs, mapping, true).eq(new BooleanLiteral(qs, mapping, true));
                    }
                }
                else
                {
                    // Assumed to be in the right class
                    return new BooleanLiteral(qs, mapping, true).eq(new BooleanLiteral(qs, mapping, true));
                }
            }
        }
        else
        {
            // Invalid to use "XX instanceof YY" where YY is not a class.
            throw new JPOXUserException(LOCALISER.msg("037007", expr.getClass().getName()));
        }
    }
View Full Code Here

        this.storeMgr = datastoreContainer.getStoreManager();

        ContainerMetaData conmd = fmd.getContainer();
        if (conmd == null)
        {
            throw new JPOXUserException(LOCALISER.msg("041023", fmd.getFullFieldName()));
        }

        if (!containerIsStoredInSingleColumn())
        {
            // Not serialised so we use JoinTable or ForeignKey
View Full Code Here

        return ClassNameConstants.JAVA_IO_SERIALIZABLE;
    }

    public ScalarExpression newLiteral(QueryExpression qExpr, Object literal)
    {
        throw new JPOXUserException(getJavaType().getName()+" is not supported in queries.").setFatal();
    }
View Full Code Here

        throw new JPOXUserException(getJavaType().getName()+" is not supported in queries.").setFatal();
    }

    public ScalarExpression newScalarExpression(QueryExpression qExpr, LogicSetExpression expr)
    {
        throw new JPOXUserException(getJavaType().getName()+" is not supported in queries.").setFatal();
    }   
View Full Code Here

            return new SqlTimestampLiteral(qs, this, (Timestamp)value);
        }
        else
        {
            // [CORE-2802]
            throw new JPOXUserException("JPOX doesnt support querying of Calendar fields when stored as 2 columns");
        }
    }
View Full Code Here

            return new SqlTemporalExpression(qs, this, te);
        }
        else
        {
            // [CORE-2802]
            throw new JPOXUserException("JPOX doesnt support querying of Calendar fields when stored as 2 columns");
        }
    }
View Full Code Here

TOP

Related Classes of org.jpox.exceptions.JPOXUserException

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.