db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mpoes...@apache.org
Subject cvs commit: db-torque/src/java/org/apache/torque/util BasePeer.java
Date Fri, 21 Mar 2003 22:14:04 GMT
mpoeschl    2003/03/21 14:14:04

  Modified:    src/java/org/apache/torque/util BasePeer.java
  Log:
  formatting
  
  Revision  Changes    Path
  1.63      +56 -111   db-torque/src/java/org/apache/torque/util/BasePeer.java
  
  Index: BasePeer.java
  ===================================================================
  RCS file: /home/cvs/db-torque/src/java/org/apache/torque/util/BasePeer.java,v
  retrieving revision 1.62
  retrieving revision 1.63
  diff -u -r1.62 -r1.63
  --- BasePeer.java	21 Mar 2003 17:31:08 -0000	1.62
  +++ BasePeer.java	21 Mar 2003 22:14:03 -0000	1.63
  @@ -252,8 +252,7 @@
           catch (Exception e)
           {
               category.error(e);
  -            throw new Error(
  -                "Error in BasePeer.initTableSchema("
  +            throw new Error("Error in BasePeer.initTableSchema("
                       + tableName
                       + "): "
                       + e.getMessage());
  @@ -353,8 +352,7 @@
               statement = con.createStatement();
   
               StringBuffer query = new StringBuffer();
  -            query
  -                .append("DELETE FROM ")
  +            query.append("DELETE FROM ")
                   .append(table)
                   .append(" WHERE ")
                   .append(column)
  @@ -423,8 +421,7 @@
           Connection con = null;
           try
           {
  -            con =
  -                Transaction.beginOptional(
  +            con = Transaction.beginOptional(
                       criteria.getDbName(),
                       criteria.isUseTransaction());
               doDelete(criteria, con);
  @@ -466,8 +463,7 @@
                   String tableName2 = criteria.getTableForAlias(tableNames[i]);
                   if (tableName2 != null)
                   {
  -                    tables.add(
  -                        new StringBuffer(
  +                    tables.add(new StringBuffer(
                               tableNames[i].length() + tableName2.length() + 1)
                               .append(tableName2)
                               .append(' ')
  @@ -497,8 +493,7 @@
                               && key.equals(columnMaps[j].getRelatedName()))
                           {
                               tables.add(tableMaps[i].getName());
  -                            criteria.add(
  -                                columnMaps[j].getFullyQualifiedName(),
  +                            criteria.add(columnMaps[j].getFullyQualifiedName(),
                                   criteria.getValue(key));
                           }
                       }
  @@ -520,8 +515,7 @@
                   {
                       kd.addAttrib(colMap.getColumnName());
                   }
  -                String key =
  -                    new StringBuffer(colMap.getTableName())
  +                String key = new StringBuffer(colMap.getTableName())
                           .append('.')
                           .append(colMap.getColumnName())
                           .toString();
  @@ -533,8 +527,7 @@
                       }
                       else
                       {
  -                        whereClause.add(
  -                            SqlExpression.build(
  +                        whereClause.add(SqlExpression.build(
                                   colMap.getColumnName(),
                                   criteria.getValue(key),
                                   criteria.getComparison(key),
  @@ -617,8 +610,7 @@
   
           try
           {
  -            con =
  -                Transaction.beginOptional(
  +            con = Transaction.beginOptional(
                       criteria.getDbName(),
                       criteria.isUseTransaction());
               id = doInsert(criteria, con);
  @@ -673,8 +665,7 @@
           }
           else
           {
  -            throw new TorqueException(
  -                "Database insert attempted without "
  +            throw new TorqueException("Database insert attempted without "
                       + "anything specified to insert");
           }
   
  @@ -703,8 +694,7 @@
                   {
                       if (pk.getType() instanceof Number)
                       {
  -                        id =
  -                            new NumberKey(
  +                        id = new NumberKey(
                                   keyGen.getIdAsBigDecimal(con, keyInfo));
                       }
                       else
  @@ -794,8 +784,7 @@
           for (int j = 0; j < columnMaps.length; j++)
           {
               ColumnMap colMap = columnMaps[j];
  -            String key =
  -                new StringBuffer(colMap.getTableName())
  +            String key = new StringBuffer(colMap.getTableName())
                       .append('.')
                       .append(colMap.getColumnName())
                       .toString();
  @@ -820,9 +809,8 @@
                       }
                       else if (obj instanceof Integer)
                       {
  -                        rec.setValue(
  -                            colMap.getColumnName(),
  -                            criteria.getInt(key));
  +                        rec.setValue(colMap.getColumnName(),
  +                                criteria.getInt(key));
                       }
                       else if (obj instanceof BigDecimal)
                       {
  @@ -830,50 +818,42 @@
                       }
                       else if (obj instanceof Boolean)
                       {
  -                        rec.setValue(
  -                            colMap.getColumnName(),
  +                        rec.setValue(colMap.getColumnName(),
                               criteria.getBoolean(key) ? 1 : 0);
                       }
                       else if (obj instanceof java.util.Date)
                       {
  -                        rec.setValue(
  -                            colMap.getColumnName(),
  +                        rec.setValue(colMap.getColumnName(),
                               (java.util.Date) obj);
                       }
                       else if (obj instanceof Float)
                       {
  -                        rec.setValue(
  -                            colMap.getColumnName(),
  +                        rec.setValue(colMap.getColumnName(),
                               criteria.getFloat(key));
                       }
                       else if (obj instanceof Double)
                       {
  -                        rec.setValue(
  -                            colMap.getColumnName(),
  +                        rec.setValue(colMap.getColumnName(),
                               criteria.getDouble(key));
                       }
                       else if (obj instanceof Byte)
                       {
  -                        rec.setValue(
  -                            colMap.getColumnName(),
  +                        rec.setValue(colMap.getColumnName(),
                               ((Byte) obj).byteValue());
                       }
                       else if (obj instanceof Long)
                       {
  -                        rec.setValue(
  -                            colMap.getColumnName(),
  +                        rec.setValue(colMap.getColumnName(),
                               criteria.getLong(key));
                       }
                       else if (obj instanceof Short)
                       {
  -                        rec.setValue(
  -                            colMap.getColumnName(),
  +                        rec.setValue(colMap.getColumnName(),
                               ((Short) obj).shortValue());
                       }
                       else if (obj instanceof Hashtable)
                       {
  -                        rec.setValue(
  -                            colMap.getColumnName(),
  +                        rec.setValue(colMap.getColumnName(),
                               hashtableToByteArray((Hashtable) obj));
                       }
                       else if (obj instanceof byte[])
  @@ -995,10 +975,8 @@
                   // resultset since the results are limited on the server.
                   criteria.setLimit(-1);
               }
  -
               sql = query.toString();
           }
  -
           category.debug(sql);
           return sql;
       }
  @@ -1066,8 +1044,7 @@
               String tableName2 = criteria.getTableForAlias(tableName);
               if (tableName2 != null)
               {
  -                fromClause.add(
  -                    new StringBuffer(
  +                fromClause.add(new StringBuffer(
                           tableName.length() + tableName2.length() + 1)
                           .append(tableName2)
                           .append(' ')
  @@ -1102,8 +1079,7 @@
                   table = criteria.getTableForAlias(tableName);
                   if (table != null)
                   {
  -                    fromClause.add(
  -                        new StringBuffer(
  +                    fromClause.add(new StringBuffer(
                               tableName.length() + table.length() + 1)
                               .append(table)
                               .append(' ')
  @@ -1116,8 +1092,7 @@
                       table = tableName;
                   }
   
  -                boolean ignorCase =
  -                    ((criteria.isIgnoreCase()
  +                boolean ignorCase = ((criteria.isIgnoreCase()
                           || someCriteria[i].isIgnoreCase())
                           && (dbMap
                               .getTable(table)
  @@ -1152,8 +1127,7 @@
                   String table = criteria.getTableForAlias(tableName);
                   if (table != null)
                   {
  -                    fromClause.add(
  -                        new StringBuffer(
  +                    fromClause.add(new StringBuffer(
                               tableName.length() + table.length() + 1)
                               .append(table)
                               .append(' ')
  @@ -1170,8 +1144,7 @@
                   table = criteria.getTableForAlias(tableName);
                   if (table != null)
                   {
  -                    fromClause.add(
  -                        new StringBuffer(
  +                    fromClause.add(new StringBuffer(
                               tableName.length() + table.length() + 1)
                               .append(table)
                               .append(' ')
  @@ -1184,8 +1157,7 @@
                       table = tableName;
                   }
   
  -                boolean ignorCase =
  -                    (criteria.isIgnoreCase()
  +                boolean ignorCase = (criteria.isIgnoreCase()
                           && (dbMap
                               .getTable(table)
                               .getColumn(join2.substring(dot + 1, join2.length()))
  @@ -1205,11 +1177,9 @@
                   String groupByColumn = groupBy.get(i);
                   if (groupByColumn.indexOf('.') == -1)
                   {
  -                    throwMalformedColumnNameException(
  -                        "group by",
  -                        groupByColumn);
  +                    throwMalformedColumnNameException("group by",
  +                            groupByColumn);
                   }
  -
                   groupByClause.add(groupByColumn);
               }
           }
  @@ -1230,9 +1200,8 @@
                   String orderByColumn = orderBy.get(i);
                   if (orderByColumn.indexOf('.') == -1)
                   {
  -                    throwMalformedColumnNameException(
  -                        "order by",
  -                        orderByColumn);
  +                    throwMalformedColumnNameException("order by",
  +                            orderByColumn);
                   }
                   String tableName =
                       orderByColumn.substring(0, orderByColumn.indexOf('.'));
  @@ -1253,10 +1222,8 @@
                   }
                   else
                   {
  -                    columnName =
  -                        orderByColumn.substring(
  -                            orderByColumn.indexOf('.') + 1,
  -                            spacePos);
  +                    columnName = orderByColumn.substring(
  +                            orderByColumn.indexOf('.') + 1, spacePos);
                   }
                   ColumnMap column = dbMap.getTable(table).getColumn(columnName);
                   if (column.getType() instanceof String)
  @@ -1264,12 +1231,11 @@
                       if (spacePos == -1)
                       {
                           orderByClause.add(
  -                            db.ignoreCaseInOrderBy(orderByColumn));
  +                                db.ignoreCaseInOrderBy(orderByColumn));
                       }
                       else
                       {
  -                        orderByClause.add(
  -                            db.ignoreCaseInOrderBy(
  +                        orderByClause.add(db.ignoreCaseInOrderBy(
                                   orderByColumn.substring(0, spacePos))
                                   + orderByColumn.substring(spacePos));
                       }
  @@ -1292,16 +1258,14 @@
               switch (db.getLimitStyle())
               {
                   case DB.LIMIT_STYLE_MYSQL :
  -                    limitString =
  -                        new StringBuffer()
  +                    limitString = new StringBuffer()
                               .append(offset)
                               .append(", ")
                               .append(limit)
                               .toString();
                       break;
                   case DB.LIMIT_STYLE_POSTGRES :
  -                    limitString =
  -                        new StringBuffer()
  +                    limitString = new StringBuffer()
                               .append(limit)
                               .append(", ")
                               .append(offset)
  @@ -1341,7 +1305,6 @@
           {
               query.setLimit(limitString);
           }
  -
           return query;
       }
   
  @@ -1360,13 +1323,11 @@
   
           try
           {
  -            con =
  -                Transaction.beginOptional(
  +            con = Transaction.beginOptional(
                       criteria.getDbName(),
                       criteria.isUseTransaction());
   
  -            results =
  -                executeQuery(
  +            results = executeQuery(
                       createQueryString(criteria),
                       criteria.getOffset(),
                       criteria.getLimit(),
  @@ -1501,8 +1462,7 @@
           {
               db = Torque.getConnection(dbName);
               // execute the query
  -            results =
  -                executeQuery(
  +            results = executeQuery(
                       queryString,
                       start,
                       numberOfResults,
  @@ -1544,12 +1504,11 @@
               // execute the query
               long startTime = System.currentTimeMillis();
               qds = new QueryDataSet(con, queryString);
  -            category.debug(
  -                "Elapsed time="
  +            category.debug("Elapsed time="
                       + (System.currentTimeMillis() - startTime)
                       + " ms");
  -            results =
  -                getSelectResults(qds, start, numberOfResults, singleRecord);
  +            results = getSelectResults(
  +                    qds, start, numberOfResults, singleRecord);
           }
           catch (Exception e)
           {
  @@ -1762,8 +1721,7 @@
           Connection con = null;
           try
           {
  -            con =
  -                Transaction.beginOptional(
  +            con = Transaction.beginOptional(
                       updateValues.getDbName(),
                       updateValues.isUseTransaction());
               doUpdate(updateValues, con);
  @@ -1804,8 +1762,7 @@
           if (pk != null && updateValues.containsKey(pk.getFullyQualifiedName()))
           {
               selectCriteria = new Criteria(2);
  -            selectCriteria.put(
  -                pk.getFullyQualifiedName(),
  +            selectCriteria.put(pk.getFullyQualifiedName(),
                   updateValues.remove(pk.getFullyQualifiedName()));
           }
           else
  @@ -2065,8 +2022,7 @@
       protected static void handleMultipleRecords(DataSet ds)
           throws TorqueException
       {
  -        throw new TorqueException(
  -            "Criteria expected single Record and "
  +        throw new TorqueException("Criteria expected single Record and "
                   + "Multiple Records were selected");
       }
   
  @@ -2194,8 +2150,7 @@
                   }
                   else if (param instanceof NumberKey)
                   {
  -                    stmt.setBigDecimal(
  -                        i + 1,
  +                    stmt.setBigDecimal(i + 1,
                           ((NumberKey) param).getBigDecimal());
                   }
                   else
  @@ -2236,7 +2191,6 @@
                   }
               }
           }
  -
           return v;
       }
   
  @@ -2261,7 +2215,6 @@
           {
               Torque.closeConnection(con);
           }
  -
           return v;
       }
   
  @@ -2380,8 +2333,7 @@
                       table = tableName;
                   }
   
  -                boolean ignorCase =
  -                    ((criteria.isIgnoreCase()
  +                boolean ignorCase = ((criteria.isIgnoreCase()
                           || someCriteria[i].isIgnoreCase())
                           && (dbMap
                               .getTable(table)
  @@ -2448,8 +2400,7 @@
                       table = tableName;
                   }
   
  -                boolean ignorCase =
  -                    (criteria.isIgnoreCase()
  +                boolean ignorCase = (criteria.isIgnoreCase()
                           && (dbMap
                               .getTable(table)
                               .getColumn(join2.substring(dot + 1, join2.length()))
  @@ -2470,8 +2421,7 @@
                   String orderByColumn = orderBy.get(i);
                   if (orderByColumn.indexOf('.') == -1)
                   {
  -                    throwMalformedColumnNameException(
  -                        "order by",
  +                    throwMalformedColumnNameException("order by",
                           orderByColumn);
                   }
                   String table =
  @@ -2487,8 +2437,7 @@
                   }
                   else
                   {
  -                    columnName =
  -                        orderByColumn.substring(
  +                    columnName = orderByColumn.substring(
                               orderByColumn.indexOf('.') + 1,
                               spacePos);
                   }
  @@ -2502,8 +2451,7 @@
                       }
                       else
                       {
  -                        orderByClause.add(
  -                            db.ignoreCaseInOrderBy(
  +                        orderByClause.add(db.ignoreCaseInOrderBy(
                                   orderByColumn.substring(0, spacePos))
                                   + orderByColumn.substring(spacePos));
                       }
  @@ -2527,16 +2475,14 @@
               switch (db.getLimitStyle())
               {
                   case DB.LIMIT_STYLE_MYSQL :
  -                    limitString =
  -                        new StringBuffer()
  +                    limitString = new StringBuffer()
                               .append(offset)
                               .append(", ")
                               .append(limit)
                               .toString();
                       break;
                   case DB.LIMIT_STYLE_POSTGRES :
  -                    limitString =
  -                        new StringBuffer()
  +                    limitString = new StringBuffer()
                               .append(limit)
                               .append(", ")
                               .append(offset)
  @@ -2643,8 +2589,7 @@
           String columnName)
           throws TorqueException
       {
  -        throw new TorqueException(
  -            "Malformed column name in Criteria "
  +        throw new TorqueException("Malformed column name in Criteria "
                   + criteriaPhrase
                   + ": '"
                   + columnName
  
  
  

Mime
View raw message