Package org.jboss.ejb.plugins.cmp.jdbc2.bridge

Examples of org.jboss.ejb.plugins.cmp.jdbc2.bridge.JDBCEntityBridge2


            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


         }
      }

      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

            int paramInd = 1;
            JDBCCMPFieldBridge2[] keyFields = (JDBCCMPFieldBridge2[])leftField.getTableKeyFields();
            for(int pkInd = 0; pkInd < keyFields.length; ++pkInd)
            {
               JDBCCMPFieldBridge2 pkField = keyFields[pkInd];
               Object fieldValue = pkField.getPrimaryKeyValue(keys.leftKey);
               paramInd = pkField.setArgumentParameters(ps, paramInd, fieldValue);
            }

            keyFields = (JDBCCMPFieldBridge2[])rightField.getTableKeyFields();
            for(int pkInd = 0; pkInd < keyFields.length; ++pkInd)
            {
               JDBCCMPFieldBridge2 pkField = keyFields[pkInd];
               Object fieldValue = pkField.getPrimaryKeyValue(keys.rightKey);
               paramInd = pkField.setArgumentParameters(ps, paramInd, fieldValue);
            }

            ps.addBatch();
            ++batchCount;
View Full Code Here

            JDBCCMPFieldBridge2[] keyFields = (JDBCCMPFieldBridge2[])leftField.getTableKeyFields();
            int paramInd = 1;
            for(int fInd = 0; fInd < keyFields.length; ++fInd)
            {
               JDBCCMPFieldBridge2 field = keyFields[fInd];
               Object fieldValue = field.getPrimaryKeyValue(keys.leftKey);
               paramInd = field.setArgumentParameters(ps, paramInd, fieldValue);
            }

            keyFields = (JDBCCMPFieldBridge2[])rightField.getTableKeyFields();
            for(int fInd = 0; fInd < keyFields.length; ++fInd)
            {
               JDBCCMPFieldBridge2 field = keyFields[fInd];
               Object fieldValue = field.getPrimaryKeyValue(keys.rightKey);
               paramInd = field.setArgumentParameters(ps, paramInd, fieldValue);
            }

            ps.addBatch();
            ++batchCount;
View Full Code Here

      // UPDATE SQL
      updateSql = "update " + tableName + " set ";
      int setFields = 0;
      for(int i = 0; i < tableFields.length; ++i)
      {
         JDBCCMPFieldBridge2 field = tableFields[i];
         if(!field.isPrimaryKeyMember())
         {
            if(setFields++ > 0)
            {
               updateSql += ", ";
            }
            updateSql += field.getColumnName() + "=?";
         }
      }
      updateSql += " where ";
      updateSql += pkFields[0].getColumnName() + "=?";
      for(int i = 1; i < pkFields.length; ++i)
      {
         updateSql += " and " + pkFields[i].getColumnName() + "=?";
      }

      if(entity.getVersionField() != null)
      {
         updateSql += " and " + entity.getVersionField().getColumnName() + "=?";
      }
      log.debug("update sql: " + updateSql);

      // SELECT SQL
      String selectColumns = tableFields[0].getColumnName();
      for(int i = 1; i < tableFields.length; ++i)
      {
         JDBCCMPFieldBridge2 field = tableFields[i];
         selectColumns += ", " + field.getColumnName();
      }

      String whereColumns = pkFields[0].getColumnName() + "=?";
      for(int i = 1; i < pkFields.length; ++i)
      {
View Full Code Here

         ps = con.prepareStatement(selectSql);

         int paramInd = 1;
         for(int i = 0; i < pkFields.length; ++i)
         {
            JDBCCMPFieldBridge2 pkField = pkFields[i];
            Object pkValue = pkField.getPrimaryKeyValue(id);
            paramInd = pkField.setArgumentParameters(ps, paramInd, pkValue);
         }

         rs = ps.executeQuery();

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

            Row row = view.deleted;

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

            deleteStrategy.executeUpdate(ps);

            ++batchCount;
View Full Code Here

            Row row = view.dirty;

            int paramInd = 1;
            for(int fInd = 0; fInd < tableFields.length; ++fInd)
            {
               JDBCCMPFieldBridge2 field = tableFields[fInd];
               if(!field.isPrimaryKeyMember())
               {
                  Object fieldValue = row.fields[field.getRowIndex()];
                  paramInd = field.setArgumentParameters(ps, paramInd, fieldValue);
               }
            }

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

            JDBCCMPFieldBridge2 versionField = entity.getVersionField();
            if(versionField != null)
            {
               int versionIndex = versionField.getVersionIndex();
               Object curVersion = row.fields[versionIndex];
               paramInd = versionField.setArgumentParameters(ps, paramInd, curVersion);

               Object newVersion = row.fields[versionField.getRowIndex()];
               row.fields[versionIndex] = newVersion;
            }

            updateStrategy.executeUpdate(ps);
View Full Code Here

            Row row = view.created;

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

            insertStrategy.executeUpdate(ps);

            ++batchCount;
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

TOP

Related Classes of org.jboss.ejb.plugins.cmp.jdbc2.bridge.JDBCEntityBridge2

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.