Package org.jboss.as.cmp.jdbc

Examples of org.jboss.as.cmp.jdbc.QLCompiler


        extends AbstractQueryCommand {
    public EJBQLQueryCommand(JDBCEntityBridge2 entity, JDBCQlQueryMetaData metadata) {
        this.entity = entity;

        JDBCStoreManager2 manager = (JDBCStoreManager2) entity.getManager();
        QLCompiler compiler = new EJBQLToSQL92Compiler(manager.getCatalog());

        try {
            compiler.compileEJBQL(
                    metadata.getEjbQl(),
                    metadata.getMethod().getReturnType(),
                    metadata.getMethod().getParameterTypes(),
                    metadata);
        } catch (Throwable t) {
            t.printStackTrace();
            throw new RuntimeException("Error compiling EJBQL statement '" + metadata.getEjbQl() + "'", t);
        }

        sql = compiler.getSQL();

        log = Logger.getLogger(getClass().getName() + "." + entity.getEntityName() + "#" + metadata.getMethod().getName());
        log.debug("sql: " + sql);

        setParameters(compiler.getInputParameters());
        setResultType(metadata.getMethod().getReturnType());

        if (!compiler.isSelectEntity()) {
            if (compiler.isSelectField()) {
                setFieldReader((JDBCCMPFieldBridge2) compiler.getSelectField());
            } else {
                setFunctionReader(compiler.getSelectFunction());
            }
        } else {
            setEntityReader((JDBCEntityBridge2) compiler.getSelectEntity(), compiler.isSelectDistinct());
        }
    }
View Full Code Here


        extends AbstractQueryCommand {
    public JBossQLQueryCommand(JDBCEntityBridge2 entity, JDBCJBossQLQueryMetaData metadata) {
        this.entity = entity;

        JDBCStoreManager2 manager = (JDBCStoreManager2) entity.getManager();
        QLCompiler compiler = new EJBQLToSQL92Compiler(manager.getCatalog());

        try {
            compiler.compileJBossQL(
                    metadata.getJBossQL(),
                    metadata.getMethod().getReturnType(),
                    metadata.getMethod().getParameterTypes(),
                    metadata);
        } catch (Throwable t) {
            t.printStackTrace();
            throw new RuntimeException("Error compiling JBossQL statement '" + metadata.getJBossQL() + "'", t);
        }

        sql = compiler.getSQL();

        setOffsetParam(compiler.getOffsetParam());
        setOffsetValue(compiler.getOffsetValue());
        setLimitParam(compiler.getLimitParam());
        setLimitValue(compiler.getLimitValue());

        log = Logger.getLogger(getClass().getName() + "." + entity.getEntityName() + "#" + metadata.getMethod().getName());
        log.debug("sql: " + sql);

        setParameters(compiler.getInputParameters());
        setResultType(metadata.getMethod().getReturnType());

        if (!compiler.isSelectEntity()) {
            if (compiler.isSelectField()) {
                setFieldReader((JDBCCMPFieldBridge2) compiler.getSelectField());
            } else {
                setFunctionReader(compiler.getSelectFunction());
            }
        } else {
            setEntityReader((JDBCEntityBridge2) compiler.getSelectEntity(), compiler.isSelectDistinct());
        }
    }
View Full Code Here

        if (log.isTraceEnabled()) {
            log.trace("executing dynamic-ql: " + args[0]);
        }

        JDBCStoreManager2 manager = (JDBCStoreManager2) entity.getManager();
        QLCompiler compiler = new EJBQLToSQL92Compiler(manager.getCatalog());
        try {
            compiler.compileJBossQL((String) args[0],
                    metadata.getMethod().getReturnType(),
                    getParamTypes(args),
                    metadata
            );
        } catch (Throwable t) {
            log.error("Error compiling JBossQL statement '" + args[0] + "'", t);
            throw new FinderException("Error compiling JBossQL statement '" + args[0] + "'");
        }

        String sql = compiler.getSQL();

        int offsetParam = compiler.getOffsetParam();
        int offsetValue = compiler.getOffsetValue();
        int limitParam = compiler.getLimitParam();
        int limitValue = compiler.getLimitValue();

        AbstractQueryCommand.ResultReader resultReader;
        if (!compiler.isSelectEntity()) {
            if (compiler.isSelectField()) {
                resultReader = new AbstractQueryCommand.FieldReader((JDBCCMPFieldBridge2) compiler.getSelectField());
            } else {
                resultReader = new AbstractQueryCommand.FunctionReader(compiler.getSelectFunction());
            }
        } else {
            resultReader = new AbstractQueryCommand.EntityReader((JDBCEntityBridge2) compiler.getSelectEntity(), compiler.isSelectDistinct());
        }

        return AbstractQueryCommand.fetchCollection(
                entity, sql, toArray(compiler.getInputParameters()),
                AbstractQueryCommand.toInt(args, offsetParam, offsetValue), AbstractQueryCommand.toInt(args, limitParam, limitValue),
                new AbstractQueryCommand.EagerCollectionStrategy(collectionFactory, resultReader, log),
                schema, (Object[]) args[1], factory, log);
    }
View Full Code Here

        if (log.isTraceEnabled()) {
            log.trace("executing dynamic-ql: " + args[0]);
        }

        JDBCStoreManager2 manager = (JDBCStoreManager2) entity.getManager();
        QLCompiler compiler = new EJBQLToSQL92Compiler(manager.getCatalog());
        try {
            compiler.compileJBossQL((String) args[0],
                    metadata.getMethod().getReturnType(),
                    getParamTypes(args),
                    metadata
            );
        } catch (Throwable t) {
            log.error("Error compiling JBossQL statement '" + args[0] + "'", t);
            throw new FinderException("Error compiling JBossQL statement '" + args[0] + "'");
        }

        String sql = compiler.getSQL();

        AbstractQueryCommand.ResultReader resultReader;
        if (!compiler.isSelectEntity()) {
            if (compiler.isSelectField()) {
                resultReader = new AbstractQueryCommand.FieldReader((JDBCCMPFieldBridge2) compiler.getSelectField());
            } else {
                resultReader = new AbstractQueryCommand.FunctionReader(compiler.getSelectFunction());
            }
        } else {
            resultReader = new AbstractQueryCommand.EntityReader((JDBCEntityBridge2) compiler.getSelectEntity(), compiler.isSelectDistinct());
        }

        return AbstractQueryCommand.fetchOne(entity, sql, toArray(compiler.getInputParameters()),
                resultReader, (Object[]) args[1], factory, log);
    }
View Full Code Here

        if (log.isTraceEnabled()) {
            log.trace("executing dynamic-ql: " + args[0]);
        }

        JDBCStoreManager2 manager = (JDBCStoreManager2) entity.getManager();
        QLCompiler compiler = new EJBQLToSQL92Compiler(manager.getCatalog());
        try {
            compiler.compileJBossQL((String) args[0],
                    metadata.getMethod().getReturnType(),
                    getParamTypes(args),
                    metadata
            );
        } catch (Throwable t) {
            throw CmpMessages.MESSAGES.errorCompilingJbossQlStatement(args[0], t);
        }

        String sql = compiler.getSQL();

        int offsetParam = compiler.getOffsetParam();
        int offsetValue = compiler.getOffsetValue();
        int limitParam = compiler.getLimitParam();
        int limitValue = compiler.getLimitValue();

        AbstractQueryCommand.ResultReader resultReader;
        if (!compiler.isSelectEntity()) {
            if (compiler.isSelectField()) {
                resultReader = new AbstractQueryCommand.FieldReader((JDBCCMPFieldBridge2) compiler.getSelectField());
            } else {
                resultReader = new AbstractQueryCommand.FunctionReader(compiler.getSelectFunction());
            }
        } else {
            resultReader = new AbstractQueryCommand.EntityReader((JDBCEntityBridge2) compiler.getSelectEntity(), compiler.isSelectDistinct());
        }

        return AbstractQueryCommand.fetchCollection(
                entity, sql, toArray(compiler.getInputParameters()),
                AbstractQueryCommand.toInt(args, offsetParam, offsetValue), AbstractQueryCommand.toInt(args, limitParam, limitValue),
                new AbstractQueryCommand.EagerCollectionStrategy(collectionFactory, resultReader, log),
                schema, (Object[]) args[1], factory, log);
    }
View Full Code Here

        if (log.isTraceEnabled()) {
            log.trace("executing dynamic-ql: " + args[0]);
        }

        JDBCStoreManager2 manager = (JDBCStoreManager2) entity.getManager();
        QLCompiler compiler = new EJBQLToSQL92Compiler(manager.getCatalog());
        try {
            compiler.compileJBossQL((String) args[0],
                    metadata.getMethod().getReturnType(),
                    getParamTypes(args),
                    metadata
            );
        } catch (Throwable t) {
            throw CmpMessages.MESSAGES.errorCompilingJbossQlStatement(args[0], t);
        }

        String sql = compiler.getSQL();

        AbstractQueryCommand.ResultReader resultReader;
        if (!compiler.isSelectEntity()) {
            if (compiler.isSelectField()) {
                resultReader = new AbstractQueryCommand.FieldReader((JDBCCMPFieldBridge2) compiler.getSelectField());
            } else {
                resultReader = new AbstractQueryCommand.FunctionReader(compiler.getSelectFunction());
            }
        } else {
            resultReader = new AbstractQueryCommand.EntityReader((JDBCEntityBridge2) compiler.getSelectEntity(), compiler.isSelectDistinct());
        }

        return AbstractQueryCommand.fetchOne(entity, sql, toArray(compiler.getInputParameters()),
                resultReader, (Object[]) args[1], factory, log);
    }
View Full Code Here

        extends AbstractQueryCommand {
    public EJBQLQueryCommand(JDBCEntityBridge2 entity, JDBCQlQueryMetaData metadata) {
        this.entity = entity;

        JDBCStoreManager2 manager = (JDBCStoreManager2) entity.getManager();
        QLCompiler compiler = new EJBQLToSQL92Compiler(manager.getCatalog());

        try {
            compiler.compileEJBQL(
                    metadata.getEjbQl(),
                    metadata.getMethod().getReturnType(),
                    metadata.getMethod().getParameterTypes(),
                    metadata);
        } catch (Throwable t) {
            throw CmpMessages.MESSAGES.errorCompilingEjbQlStatement(metadata.getEjbQl(), t);
        }

        sql = compiler.getSQL();

        log = Logger.getLogger(getClass().getName() + "." + entity.getEntityName() + "#" + metadata.getMethod().getName());
        log.debug("sql: " + sql);

        setParameters(compiler.getInputParameters());
        setResultType(metadata.getMethod().getReturnType());

        if (!compiler.isSelectEntity()) {
            if (compiler.isSelectField()) {
                setFieldReader((JDBCCMPFieldBridge2) compiler.getSelectField());
            } else {
                setFunctionReader(compiler.getSelectFunction());
            }
        } else {
            setEntityReader((JDBCEntityBridge2) compiler.getSelectEntity(), compiler.isSelectDistinct());
        }
    }
View Full Code Here

        extends AbstractQueryCommand {
    public JBossQLQueryCommand(JDBCEntityBridge2 entity, JDBCJBossQLQueryMetaData metadata) {
        this.entity = entity;

        JDBCStoreManager2 manager = (JDBCStoreManager2) entity.getManager();
        QLCompiler compiler = new EJBQLToSQL92Compiler(manager.getCatalog());

        try {
            compiler.compileJBossQL(
                    metadata.getJBossQL(),
                    metadata.getMethod().getReturnType(),
                    metadata.getMethod().getParameterTypes(),
                    metadata);
        } catch (Throwable t) {
            throw CmpMessages.MESSAGES.errorCompilingJbossQlStatementRuntime(metadata.getJBossQL(), t);
        }

        sql = compiler.getSQL();

        setOffsetParam(compiler.getOffsetParam());
        setOffsetValue(compiler.getOffsetValue());
        setLimitParam(compiler.getLimitParam());
        setLimitValue(compiler.getLimitValue());

        log = Logger.getLogger(getClass().getName() + "." + entity.getEntityName() + "#" + metadata.getMethod().getName());
        log.debug("sql: " + sql);

        setParameters(compiler.getInputParameters());
        setResultType(metadata.getMethod().getReturnType());

        if (!compiler.isSelectEntity()) {
            if (compiler.isSelectField()) {
                setFieldReader((JDBCCMPFieldBridge2) compiler.getSelectField());
            } else {
                setFunctionReader(compiler.getSelectFunction());
            }
        } else {
            setEntityReader((JDBCEntityBridge2) compiler.getSelectEntity(), compiler.isSelectDistinct());
        }
    }
View Full Code Here

TOP

Related Classes of org.jboss.as.cmp.jdbc.QLCompiler

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.