db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tfisc...@apache.org
Subject cvs commit: db-torque/src/java/org/apache/torque/util SQLBuilder.java Criteria.java
Date Fri, 18 Feb 2005 10:04:38 GMT
tfischer    2005/02/18 02:04:38

  Modified:    src/java/org/apache/torque/util SQLBuilder.java
                        Criteria.java
  Log:
  allow dots in autogenerated table names
  This is a first step towards support of fully qualified table names (<table name="schema_name.table_name"
... >) in the generator.
  I did not notice any further problems with such table names in the runtime.
  The generator still produces invalid java names, but this can be overridden via the javaName
attribute of the table tag.
  
  Revision  Changes    Path
  1.3       +6 -9      db-torque/src/java/org/apache/torque/util/SQLBuilder.java
  
  Index: SQLBuilder.java
  ===================================================================
  RCS file: /home/cvs/db-torque/src/java/org/apache/torque/util/SQLBuilder.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SQLBuilder.java	31 Jan 2005 19:43:52 -0000	1.2
  +++ SQLBuilder.java	18 Feb 2005 10:04:37 -0000	1.3
  @@ -470,17 +470,16 @@
               for (int i = 0; i < orderBy.size(); i++)
               {
                   String orderByColumn = (String) orderBy.get(i);
  -                if (orderByColumn.indexOf('.') == -1)
  +                int dotPos = orderByColumn.lastIndexOf('.');
  +                if (dotPos == -1)
                   {
                       throwMalformedColumnNameException(
                               "order by",
                               orderByColumn);
                   }
   
  -                //String table =
  -                //    orderByColumn.substring(0, orderByColumn.lastIndexOf('.'));
                   String tableName =
  -                        orderByColumn.substring(0, orderByColumn.indexOf('.'));
  +                        orderByColumn.substring(0, dotPos);
                   String table = crit.getTableForAlias(tableName);
                   if (table == null)
                   {
  @@ -494,13 +493,11 @@
                   if (spacePos == -1)
                   {
                       columnName =
  -                            orderByColumn.substring(orderByColumn.indexOf('.') + 1);
  +                            orderByColumn.substring(dotPos + 1);
                   }
                   else
                   {
  -                    columnName = orderByColumn.substring(
  -                            orderByColumn.indexOf('.') + 1,
  -                            spacePos);
  +                    columnName = orderByColumn.substring(dotPos + 1, spacePos);
                   }
                   ColumnMap column = dbMap.getTable(table).getColumn(columnName);
                   if (column.getType() instanceof String)
  
  
  
  1.46      +2 -2      db-torque/src/java/org/apache/torque/util/Criteria.java
  
  Index: Criteria.java
  ===================================================================
  RCS file: /home/cvs/db-torque/src/java/org/apache/torque/util/Criteria.java,v
  retrieving revision 1.45
  retrieving revision 1.46
  diff -u -r1.45 -r1.46
  --- Criteria.java	31 Jan 2005 19:43:52 -0000	1.45
  +++ Criteria.java	18 Feb 2005 10:04:37 -0000	1.46
  @@ -3070,7 +3070,7 @@
           Criterion(String tableColumn, Object val, SqlEnum comp)
           {
               this(val, comp);
  -            int dot = tableColumn.indexOf('.');
  +            int dot = tableColumn.lastIndexOf('.');
               if (dot == -1)
               {
                   table = "";
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


Mime
View raw message