Package org.datanucleus.exceptions

Examples of org.datanucleus.exceptions.NucleusException


     */
    public SQLExpression getExpression(SQLExpression expr, List args)
    {
        if (args == null || args.size() != 2)
        {
            throw new NucleusException(LOCALISER.msg("060003", "replaceAll", "StringExpression", 2,
                "StringExpression/CharacterExpression"));
        }
        else
        {
            // {strExpr}.translate(strExpr1, strExpr2)
            SQLExpression strExpr1 = (SQLExpression)args.get(0);
            SQLExpression strExpr2 = (SQLExpression)args.get(1);
            if (!(strExpr1 instanceof StringExpression) &&
                !(strExpr1 instanceof CharacterExpression))
            {
                throw new NucleusException(LOCALISER.msg("060003", "replaceAll", "StringExpression", 1,
                    "StringExpression/CharacterExpression"));
            }
            if (!(strExpr2 instanceof StringExpression) &&
                !(strExpr2 instanceof CharacterExpression))
            {
                throw new NucleusException(LOCALISER.msg("060003", "replaceAll", "StringExpression", 2,
                    "StringExpression/CharacterExpression"));
            }

            // Invoke substring(startExpr, endExpr)
            List<SQLExpression> newArgs = new ArrayList<SQLExpression>(3);
View Full Code Here


     */
    public SQLExpression getExpression(SQLExpression expr, List args)
    {
        if (!(expr instanceof TemporalExpression))
        {
            throw new NucleusException(LOCALISER.msg("060001", "getMinute()", expr));
        }

        RDBMSStoreManager storeMgr = stmt.getRDBMSManager();
        JavaTypeMapping mapping = storeMgr.getMappingManager().getMapping(String.class);
        SQLExpression mi = exprFactory.newLiteral(stmt, mapping, "MI");
View Full Code Here

        {
            this.value = (Number)value;
        }
        else
        {
            throw new NucleusException("Cannot create " + this.getClass().getName() +
                " for value of type " + (value != null ? value.getClass().getName() : null));
        }

        if (parameterName != null)
        {
View Full Code Here

    {
        if (expr == null)
        {
            if (args == null || args.size() != 1)
            {
                throw new NucleusException(getFunctionName() + " is only supported with a single argument");
            }
            JavaTypeMapping m = null;
            if (args.get(0) instanceof SQLExpression)
            {
                // Use same java type as the argument
                SQLExpression argExpr = (SQLExpression)args.get(0);
                Class cls = argExpr.getJavaTypeMapping().getJavaType();
                if (cls == Integer.class || cls == Short.class || cls == Long.class)
                {
                    m = getMappingForClass(Long.class);
                }
                else if (Number.class.isAssignableFrom(cls))
                {
                    m = getMappingForClass(argExpr.getJavaTypeMapping().getJavaType());
                }
                else
                {
                    throw new NucleusUserException("Cannot perform SUM on " + expr + " of type " + cls.getName());
                }
            }
            else
            {
                // Fallback to the type for this aggregate
                m = getMappingForClass(getClassForMapping());
            }
            return new AggregateNumericExpression(stmt, m, getFunctionName(), args);
        }
        else
        {
            throw new NucleusException(LOCALISER.msg("060002", getFunctionName(), expr));
        }
    }
View Full Code Here

    public synchronized void populate(ClassLoaderResolver clr, ClassLoader primary, MetaDataManager mmgr)
    {
        if (isInitialised() || isPopulated())
        {
            NucleusLogger.METADATA.error(LOCALISER.msg("044068",name));
            throw new NucleusException(LOCALISER.msg("044068",fullName)).setFatal();
        }
        if (populating)
        {
            return;
        }
View Full Code Here

     */
    public SQLExpression getExpression(SQLExpression expr, List args)
    {
        if (args == null || args.size() == 0 || args.size() > 1)
        {
            throw new NucleusException(LOCALISER.msg("060016", "containsValue", "MapExpression", 1));
        }

        MapExpression mapExpr = (MapExpression)expr;
        SQLExpression valExpr = (SQLExpression)args.get(0);

View Full Code Here

    {
        if (url == null)
        {
            String msg = LOCALISER.msg("044031");
            NucleusLogger.METADATA.error(msg);
            throw new NucleusException(msg);
        }

        InputStream in = null;
        try
        {
            in = url.openStream();
        }
        catch (Exception ignore)
        {
        }
        if (in == null)
        {
            try
            {
                in = new FileInputStream(StringUtils.getFileForFilename(url.getFile()));
            }
            catch (Exception ignore)
            {
            }
        }
        if (in == null)
        {
            NucleusLogger.METADATA.error(LOCALISER.msg("044032", url.toString()));
            throw new NucleusException(LOCALISER.msg("044032", url.toString()));
        }

        // Parse the file
        return parseMetaDataStream(in, url.toString(), handlerName);
    }
View Full Code Here

            }
        }
        if (in == null)
        {
            NucleusLogger.METADATA.error(LOCALISER.msg("044032", fileName));
            throw new NucleusException(LOCALISER.msg("044032", fileName));
        }

        // Parse the file
        return parseMetaDataStream(in, fileName, handlerName);
    }
View Full Code Here

                }
            }
            catch (Exception e)
            {
                String msg = LOCALISER.msg("044029", handlerName, e.getMessage());
                throw new NucleusException(msg, e);
            }

            // Set whether to validate
            ((AbstractMetaDataHandler)handler).setValidate(validate);

            // Parse the metadata
            parser.parse(in, handler);

            // Return the FileMetaData that has been parsed
            return ((AbstractMetaDataHandler)handler).getMetaData();
        }
        catch (NucleusException e)
        {
            throw e;
        }
        catch (Exception e)
        {
            Throwable cause = e;
            if (e instanceof SAXException)
            {
                SAXException se = (SAXException)e;
                cause = se.getException();
            }
            cause = e.getCause() == null ? cause : e.getCause();

            NucleusLogger.METADATA.error(LOCALISER.msg("044040", filename, cause));
            if (cause instanceof InvalidMetaDataException)
            {
                throw (InvalidMetaDataException)cause;
            }
            else
            {
                String message = LOCALISER.msg("044033", e);
                throw new NucleusException(message, cause);
            }
        }
        finally
        {
            try
View Full Code Here

     */
    public SQLExpression getExpression(SQLExpression expr, List args)
    {
        if (args == null || args.size() == 0 || args.size() > 2)
        {
            throw new NucleusException(LOCALISER.msg("060003", "indexOf", "StringExpression", 0,
                "StringExpression/CharacterExpression/ParameterLiteral"));
        }
        else
        {
            // {stringExpr}.indexOf(strExpr1 [,numExpr2])
            SQLExpression one = ExpressionUtils.getLiteralForOne(stmt);

            ArrayList funcArgs = new ArrayList();
            funcArgs.add(expr);

            List funcArgs2 = new ArrayList();
            SQLExpression substrExpr = (SQLExpression)args.get(0);
            if (!(substrExpr instanceof StringExpression) &&
                !(substrExpr instanceof CharacterExpression) &&
                !(substrExpr instanceof ParameterLiteral))
            {
                throw new NucleusException(LOCALISER.msg("060003", "indexOf", "StringExpression", 0,
                    "StringExpression/CharacterExpression/ParameterLiteral"));
            }
            funcArgs2.add(substrExpr);

            List types = new ArrayList();
            types.add("VARCHAR(4000)"); // max 4000 according DB2 docs
            funcArgs.add(new StringExpression(stmt, getMappingForClass(String.class), "CAST", funcArgs2, types));

            if (args.size() == 2)
            {
                SQLExpression fromExpr = (SQLExpression)args.get(1);
                if (!(fromExpr instanceof NumericExpression))
                {
                    throw new NucleusException(LOCALISER.msg("060003", "indexOf", "StringExpression", 1,
                        "NumericExpression"));
                }
                types = new ArrayList();
                types.add("BIGINT");

View Full Code Here

TOP

Related Classes of org.datanucleus.exceptions.NucleusException

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.