Package org.datanucleus.query.symbol

Examples of org.datanucleus.query.symbol.Symbol


    }
   
    protected boolean applyImplicitParameterValueToSubqueries(String name, Object value, QueryCompilation comp)
    {
      boolean symbolFound = false;
      Symbol sym = null;
        // Apply to any subqueries
        String[] subqueryNames = comp.getSubqueryAliases();
        if (subqueryNames != null)
        {
            for (int i=0;i<subqueryNames.length;i++)
            {
                QueryCompilation subCompilation = comp.getCompilationForSubquery(subqueryNames[i]);
                sym = subCompilation.getSymbolTable().getSymbol(name);
                if (sym != null)
                {
                    symbolFound = true;
                    if (sym.getValueType() == null && value != null)
                    {
                        // Update the compilation providing the type of this parameter
                        sym.setValueType(value.getClass());
                    }
                    else if (sym.getValueType() != null && value != null)
                    {
                        if (!QueryUtils.queryParameterTypesAreCompatible(sym.getValueType(), value.getClass()))
                        {
                            // Parameter value supplied is not consistent with what the query compilation expects
                            throw new QueryInvalidParametersException("Parameter " + name +
                                " needs to be assignable from " + sym.getValueType().getName() +
                                " yet the value is of type " + value.getClass().getName());
                        }
                    }
                }
                boolean subSymbolFound = applyImplicitParameterValueToSubqueries(name, value, subCompilation);
View Full Code Here


        Iterator it = parameterValues.entrySet().iterator();
        while (it.hasNext())
        {
            Map.Entry entry = (Map.Entry)it.next();
            Object paramKey = entry.getKey();
            Symbol sym = null;

            // Find the symbol for the parameter in the compilation (or subquery compilations)
            sym = deepFindSymbolForParameterInCompilation(compilation, paramKey);

            if (sym != null)
            {
                Class expectedValueType = sym.getValueType();
                if (entry.getValue() != null && expectedValueType != null &&
                     !QueryUtils.queryParameterTypesAreCompatible(expectedValueType, entry.getValue().getClass()))
                {
                    // Supplied parameter value is of inconsistent type
                    throw new NucleusUserException("Parameter \"" + paramKey + "\" was specified as " +
View Full Code Here

            Collection<String> symNames = symtbl.getSymbolNames();
            if (symNames != null && !symNames.isEmpty())
            {
                for (String symName : symNames)
                {
                    Symbol sym = symtbl.getSymbol(symName);
                    if (sym.getType() == Symbol.PARAMETER)
                    {
                        if (!parameterValues.containsKey(symName))
                        {
                            throw new QueryInvalidParametersException(LOCALISER.msg("021119", symName));
                        }
View Full Code Here

        }
    }

    protected Symbol deepFindSymbolForParameterInCompilation(QueryCompilation compilation, Object paramKey)
    {
        Symbol sym = null;
        sym = getSymbolForParameterInCompilation(compilation, paramKey);
        if (sym == null)
        {
            String[] subqueryNames = compilation.getSubqueryAliases();
            if (subqueryNames != null)
View Full Code Here

     * @param paramKey The parameter name/position
     * @return The symbol (if present)
     */
    private Symbol getSymbolForParameterInCompilation(QueryCompilation compilation, Object paramKey)
    {
        Symbol sym = null;
        if (paramKey instanceof Integer)
        {
            ParameterExpression expr = compilation.getParameterExpressionForPosition((Integer)paramKey);
            if (expr != null)
            {
View Full Code Here

            + qd.joinVariableExpression.getId() + ")");
      }
      Class<?> joinedClass = getSymbolTable().getSymbol(qd.joinVariableExpression.getId()).getValueType();
      return getMetaDataManager().getMetaDataForClass(joinedClass, getClassLoaderResolver());
    }
    Symbol sym = getSymbolTable().getSymbol(tuples.get(0));
    tuples.remove(0);
    return getMetaDataManager().getMetaDataForClass(sym.getValueType(), getClassLoaderResolver());
  }
View Full Code Here

            + qd.joinVariableExpression.getId() + ")");
      }
      Class<?> joinedClass = getSymbolTable().getSymbol(qd.joinVariableExpression.getId()).getValueType();
      return getMetaDataManager().getMetaDataForClass(joinedClass, getClassLoaderResolver());
    }
    Symbol sym = getSymbolTable().getSymbol(tuples.get(0));
    tuples.remove(0);
    return getMetaDataManager().getMetaDataForClass(sym.getValueType(), getClassLoaderResolver());
  }
View Full Code Here

            + qd.joinVariableExpression.getId() + ")");
      }
      Class<?> joinedClass = getSymbolTable().getSymbol(qd.joinVariableExpression.getId()).getValueType();
      return getMetaDataManager().getMetaDataForClass(joinedClass, getClassLoaderResolver());
    }
    Symbol sym = getSymbolTable().getSymbol(tuples.get(0));
    tuples.remove(0);
    return getMetaDataManager().getMetaDataForClass(sym.getValueType(), getClassLoaderResolver());
  }
View Full Code Here

            for (int i = 0; i < ids.size(); i++) {
                id = ids.get(i);
               
                // Load up the class meta data from the symbol (e.g. Select o.Id From User o
                // will load the metadata for User from the alias 'o')
                Symbol symbol = query.getCompilation().getSymbolTable().getSymbol(id);
                if (symbol != null) {
                    cmd = ec.getMetaDataManager().getMetaDataForClass(symbol.getValueType(), ec.getClassLoaderResolver());
                    exprMetaData.setClassMetaData(cmd);
                   
                // Get the member meta data from the class loaded above
                } else if (cmd != null) {
                    mmd = cmd.getMetaDataForMember(id);
View Full Code Here

        AbstractMemberMetaData mmd = null;
        List<String> ids = pe.getTuples();
        String id = null;
        for (int i = 0; i < ids.size(); i++) {
            id = ids.get(i);
            Symbol symbol = compilation.getSymbolTable().getSymbol(id);
            if (symbol != null) {
                cmd = ec.getMetaDataManager().getMetaDataForClass(symbol.getValueType(), ec.getClassLoaderResolver());
            } else {
                mmd = cmd.getMetaDataForMember(id);
                if (mmd == null) {
                    throw new NucleusUserException("Symbol not found, entity: " + cmd.getName() + " symbol: " + id);
                }
View Full Code Here

TOP

Related Classes of org.datanucleus.query.symbol.Symbol

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.