Package org.jboss.as.cmp.jdbc2.schema

Examples of org.jboss.as.cmp.jdbc2.schema.Cache$CacheLoader


            // this rsOffset is kind of a hack
            // but since tableIndex and rowIndex of a field are the same
            // this should work ok
            int rsOffset = 1;
            for (int i = 0; i < tableFields.length; ++i) {
                JDBCCMPFieldBridge2 field = tableFields[i];
                if (searchableOnly && !field.getJDBCType().isSearchable()) {
                    row.fields[field.getRowIndex()] = NOT_LOADED;
                    --rsOffset;
                    continue;
                }

                Object columnValue = field.loadArgumentResults(rs, field.getRowIndex() + rsOffset);
                row.fields[field.getRowIndex()] = columnValue;

                if (field.getVersionIndex() != -1) {
                    row.fields[field.getVersionIndex()] = columnValue;
                }
            }

            Object[] relations = (relationsTotal > 0 ? new Object[relationsTotal] : null);
View Full Code Here


        public Object loadPk(ResultSet rs) {
            Object pk = null;
            JDBCCMPFieldBridge2[] pkFields = (JDBCCMPFieldBridge2[]) entity.getPrimaryKeyFields();
            //int rsInd = 1;
            for (int i = 0; i < pkFields.length; ++i) {
                JDBCCMPFieldBridge2 field = pkFields[i];
                //Object columnValue = field.loadArgumentResults(rs, rsInd++);
                Object columnValue = field.loadArgumentResults(rs, field.getRowIndex() + 1);
                pk = field.setPrimaryKeyValue(pk, columnValue);
            }
            return pk;
        }
View Full Code Here

                            ps[c] = s;
                        }

                        int paramInd = 1;
                        for (int fInd = 0; fInd < pkFields.length; ++fInd) {
                            JDBCCMPFieldBridge2 pkField = pkFields[fInd];
                            Object fieldValue = row.fields[pkField.getRowIndex()];
                            paramInd = pkField.setArgumentParameters(s, paramInd, fieldValue);
                        }

                        final int affected = s.executeUpdate();
                        if (affected != 1) {
                            throw CmpMessages.MESSAGES.tooManyRowsAffected(affected);
View Full Code Here

                insertPs = con.prepareStatement(insertSql);

                paramInd = 1;
                JDBCCMPFieldBridge2[] tableFields = (JDBCCMPFieldBridge2[]) entity.getTableFields();
                for (int fInd = 0; fInd < tableFields.length; ++fInd) {
                    JDBCCMPFieldBridge2 field = tableFields[fInd];
                    Object fieldValue = fields[field.getRowIndex()];
                    paramInd = field.setArgumentParameters(insertPs, paramInd, fieldValue);
                }

                insertPs.executeUpdate();

                flushStatus();
View Full Code Here

                JDBCUtil.safeClose(con);
            }
        }

        private Object loadField(int i) {
            JDBCCMPFieldBridge2 field = (JDBCCMPFieldBridge2) entity.getFields().get(i);

            StringBuffer query = new StringBuffer();
            query.append("select ")
                    .append(field.getColumnName())
                    .append(" from ")
                    .append(tableName)
                    .append(" where ");

            JDBCCMPFieldBridge2[] pkFields = (JDBCCMPFieldBridge2[]) entity.getPrimaryKeyFields();
            for (int pkI = 0; pkI < pkFields.length; ++pkI) {
                if (pkI > 0) {
                    query.append(" and ");
                }
                query.append(pkFields[pkI].getColumnName()).append("=?");
            }

            if (log.isDebugEnabled()) {
                log.debug("executing: " + query.toString());
            }

            Object value = null;
            Connection con = null;
            PreparedStatement ps = null;
            ResultSet rs = null;

            try {
                con = dataSource.getConnection();
                ps = con.prepareStatement(query.toString());

                for (int pkI = 0; pkI < pkFields.length; ++pkI) {
                    JDBCCMPFieldBridge2 pkField = pkFields[pkI];
                    Object fieldValue = fields[pkField.getRowIndex()];
                    pkField.setArgumentParameters(ps, pkI + 1, fieldValue);
                }

                rs = ps.executeQuery();

                if (!rs.next()) {
View Full Code Here

            created = row;
            row.state = CREATED;

            rowByPk.put(row.pk, row);

            JDBCCMPFieldBridge2 versionField = entity.getVersionField();
            if (versionField != null) {
                row.fields[versionField.getVersionIndex()] = row.fields[versionField.getRowIndex()];
            }
        }
View Full Code Here

            // this rsOffset is kind of a hack
            // but since tableIndex and rowIndex of a field are the same
            // this should work ok
            int rsOffset = 1;
            for (int i = 0; i < tableFields.length; ++i) {
                JDBCCMPFieldBridge2 field = tableFields[i];
                if (searchableOnly && !field.getJDBCType().isSearchable()) {
                    row.fields[field.getRowIndex()] = NOT_LOADED;
                    --rsOffset;
                    continue;
                }

                Object columnValue = field.loadArgumentResults(rs, field.getRowIndex() + rsOffset);
                row.fields[field.getRowIndex()] = columnValue;

                if (field.getVersionIndex() != -1) {
                    row.fields[field.getVersionIndex()] = columnValue;
                }
            }

            Object[] relations = (relationsTotal > 0 ? new Object[relationsTotal] : null);
View Full Code Here

        public Object loadPk(ResultSet rs) {
            Object pk = null;
            JDBCCMPFieldBridge2[] pkFields = (JDBCCMPFieldBridge2[]) entity.getPrimaryKeyFields();
            //int rsInd = 1;
            for (int i = 0; i < pkFields.length; ++i) {
                JDBCCMPFieldBridge2 field = pkFields[i];
                //Object columnValue = field.loadArgumentResults(rs, rsInd++);
                Object columnValue = field.loadArgumentResults(rs, field.getRowIndex() + 1);
                pk = field.setPrimaryKeyValue(pk, columnValue);
            }
            return pk;
        }
View Full Code Here

                            ps[c] = s;
                        }

                        int paramInd = 1;
                        for (int fInd = 0; fInd < pkFields.length; ++fInd) {
                            JDBCCMPFieldBridge2 pkField = pkFields[fInd];
                            Object fieldValue = row.fields[pkField.getRowIndex()];
                            paramInd = pkField.setArgumentParameters(s, paramInd, fieldValue);
                        }

                        final int affected = s.executeUpdate();
                        if (affected != 1) {
                            throw new EJBException("Affected " + affected + " rows while expected just one");
View Full Code Here

                insertPs = con.prepareStatement(insertSql);

                paramInd = 1;
                JDBCCMPFieldBridge2[] tableFields = (JDBCCMPFieldBridge2[]) entity.getTableFields();
                for (int fInd = 0; fInd < tableFields.length; ++fInd) {
                    JDBCCMPFieldBridge2 field = tableFields[fInd];
                    Object fieldValue = fields[field.getRowIndex()];
                    paramInd = field.setArgumentParameters(insertPs, paramInd, fieldValue);
                }

                insertPs.executeUpdate();

                flushStatus();
View Full Code Here

TOP

Related Classes of org.jboss.as.cmp.jdbc2.schema.Cache$CacheLoader

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.