Package com.scooterframework.orm.sqldataexpress.object

Examples of com.scooterframework.orm.sqldataexpress.object.JdbcStatement


       
        String jdbcStatementString = SqlConfig.getInstance().getSql(name);
        if (jdbcStatementString == null || "".equals(jdbcStatementString.trim()))
            throw new LookupFailureException("There is no sql statement for " + name + ".");
       
        return new JdbcStatement(name, jdbcStatementString);
    }
View Full Code Here


    // find the jdbc statement from cache
    public static JdbcStatement createJdbcStatementDirect(String jdbcStatementString) {
        if (jdbcStatementString == null)
            throw new IllegalArgumentException("SQL statement string is empty.");
       
        return new JdbcStatement(jdbcStatementString, jdbcStatementString);
    }
View Full Code Here

   
    public JdbcStatement getJdbcStatement(String name) {
        if (name == null) return null;

        String jdbcKey = getJdbcKey(name);
        JdbcStatement stmt = null;
        if (DatabaseConfig.getInstance().isInDevelopmentEnvironment()) {
            stmt = (JdbcStatement)CurrentThreadCache.get(jdbcKey);
            return stmt;
        }
       
View Full Code Here

       
        try {
            String stName = st.getName();
            autoFill(udc, inputs);
           
            JdbcStatement jstat = st;
            String originalSql = st.getOriginalJdbcStatementString();
            if(checkPagination(inputs)) {
              String pagedSql = dba.preparePaginationSql(originalSql, inputs, outputFilters);
              jstat = SqlExpressUtil.createJdbcStatementDirect(pagedSql);
            }
           
            String executableSql = jstat.getExecutableJdbcStatementString();
            executableSql = autoReplace(executableSql, inputs);
           
            log.debug("execute - parsed expecutable sql: " + executableSql);
            log.debug("execute - parsed inputs: " + inputs);
            log.debug("execute - outputFilters: " + outputFilters);
           
            boolean supportsGetGeneratedKeys = supportsGetGeneratedKeys();
            if (supportsGetGeneratedKeys && !jstat.isSelectStatement()) {
                pstmt = connection.prepareStatement(executableSql, Statement.RETURN_GENERATED_KEYS);
            }
            else {
                pstmt = connection.prepareStatement(executableSql);
            }
           
            // check if need to load parameter properties
//            if (supportParameterMetaData()) {
//                if (!jstat.hasLoadedParameterMetaData()) {
//                    //get parameter meta data if it has not been loaded
//                    ParameterMetaData pmd = pstmt.getParameterMetaData();
//                    ParameterMetaDataLoader pmdl = new ParameterMetaDataLoader(pmd, jstat);
//                    pmdl.loadParameterMetaData();
//                }
//            }
//            else {
                if (!jstat.hasLoadedParameterProperties()) {
                  synchronized(jstat) {
                    if (!jstat.hasLoadedParameterProperties()) {
                            JdbcStatementParser parser = new JdbcStatementParser(udc, jstat);
                            parser.parse();
                    }
                  }
                }
//            }
           
            Collection<Parameter> parameters = jstat.getParameters();
            log.debug("execute - parameters: " + parameters);
            Iterator<Parameter> pit = parameters.iterator();
            while(pit.hasNext()) {
                Parameter p = pit.next();
               
                String key = p.getName();
                if (!inputs.containsKey(key)) {
                  throw new Exception("There " +
                    "must be a key/value pair corresponding to key named " + key +
                    " in input parameters: " + inputs.keySet());
                }
               
                if (Parameter.MODE_IN.equals(p.getMode())) {
                    Object obj = inputs.get(key);
                    if (obj == null ||
                        "".equals(obj.toString().trim()) &&
                        p.getSqlDataType() != Types.CHAR &&
                        p.getSqlDataType() != Types.VARCHAR &&
                        p.getSqlDataType() != Types.LONGVARCHAR) {
                        setNull(pstmt, p.getIndex(), p.getSqlDataType());
                    }
                    else {
                        if(!dba.vendorSpecificSetObject(pstmt, obj, p, inputs)) {
                            if (Parameter.UNKNOWN_SQL_DATA_TYPE != p.getSqlDataType()) {
                                setObject(pstmt, obj, p);
                            }
                            else {
                                //It is up to JDBC driver's PreparedStatement implementation
                                //class to deal with. Usually the class will make a decision
                                //on which setXXX(Type) method to call based on the java
                                //class type of the obj instance.
                                pstmt.setObject(p.getIndex(), obj);
                            }
                        }
                    }
                }
            }
           
            if (jstat.isSelectStatement()) {
                rs = pstmt.executeQuery();
               
                // handle out cursors or other outputs if there is any
                if (rs != null) {
                    if (outputFilters == null || outputFilters.size() == 0) {
View Full Code Here

            selectedDataProcessor = new FunctionProcessor(function);
        }
        else if (DataProcessorTypes.NAMED_SQL_STATEMENT_PROCESSOR.equals(processorType)) {
            selectedDataProcessor = DBStore.getInstance().getJdbcStatementProcessor(processorName);
          if (selectedDataProcessor == null) {
            JdbcStatement statement = SqlExpressUtil.createJdbcStatement(processorName);
                selectedDataProcessor = new JdbcStatementProcessor(statement);
                DBStore.getInstance().addJdbcStatementProcessor(processorName,
                    (JdbcStatementProcessor)selectedDataProcessor);
          }
            setDatabaseMetaData(udc, selectedDataProcessor);
        }
        else if (DataProcessorTypes.DIRECT_SQL_STATEMENT_PROCESSOR.equals(processorType)) {
          selectedDataProcessor = DBStore.getInstance().getJdbcStatementProcessor(processorName);
          if (selectedDataProcessor == null) {
            JdbcStatement statement = SqlExpressUtil.createJdbcStatementDirect(processorName);
                selectedDataProcessor = new JdbcStatementProcessor(statement);
                DBStore.getInstance().addJdbcStatementProcessor(processorName,
                    (JdbcStatementProcessor)selectedDataProcessor);
          }
            setDatabaseMetaData(udc, selectedDataProcessor);
View Full Code Here

TOP

Related Classes of com.scooterframework.orm.sqldataexpress.object.JdbcStatement

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.