db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b..@apache.org
Subject cvs commit: db-ojb/src/java/org/apache/ojb/broker/accesslayer/sql SqlQueryStatement.java
Date Fri, 23 May 2003 16:52:30 GMT
brj         2003/05/23 09:52:30

  Modified:    src/java/org/apache/ojb/broker/accesslayer/sql
                        SqlQueryStatement.java
  Log:
  fixed problems with user defined alias and m:n relationships
  
  Revision  Changes    Path
  1.39      +24 -20    db-ojb/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java
  
  Index: SqlQueryStatement.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- SqlQueryStatement.java	13 May 2003 15:23:29 -0000	1.38
  +++ SqlQueryStatement.java	23 May 2003 16:52:30 -0000	1.39
  @@ -149,6 +149,9 @@
              
           if (sp == -1)
           {
  +            // BRJ ignore alias for simple attributes 
  +            tableAlias = getRoot();
  +/*
               if (aUserAlias == null)
               {
                   tableAlias = getRoot();
  @@ -161,6 +164,7 @@
                       tableAlias = getRoot();
                   }          
               }
  +*/
           }
           else
           {
  @@ -716,8 +720,7 @@
           boolean outer = useOuterJoins;
   
   
  -        curr = getTableAliasForPath(aPath, aUserAlias);
  -        
  +        curr = getTableAliasForPath(aPath, aUserAlias);      
           
           if(curr != null)
           {
  @@ -762,23 +765,24 @@
                   }
                   else
                   {
  -                    String mnAttrPath = attrPath + "*";
  -                    indirect = getTableAliasForPath(mnAttrPath, aUserAlias, aPath);
  -                    if (indirect == null)
  -                    {
  -                        indirect = createTableAlias(cod.getIndirectionTable(), mnAttrPath,
aUserAlias, aPath);
  -
  -                        // we need two Joins for m:n
  -                        // 1.) prev class to indirectionTable
  -                        prevKeys = prev.cld.getPkFields();
  -                        join = new Join(prev, prevKeys, indirect, cod.getFksToThisClass(),
outer, attr + "*");
  -                        prev.addJoin(join);
  -
  -                        // 2.) indirectionTable to the current Class
  -                        prev = indirect;
  -                        prevKeys = cod.getFksToItemClass();
  -                        keys = cld.getPkFields();
  -                    }
  +					String mnAttrPath = attrPath + "*";
  +                    String mnPath = aPath + "*";
  +                    String mnUserAlias = (aUserAlias == null ? null : aUserAlias + "*");
  +					indirect = getTableAliasForPath(mnAttrPath, mnUserAlias, mnPath);
  +					if (indirect == null)
  +					{
  +						indirect = createTableAlias(cod.getIndirectionTable(), mnAttrPath, mnUserAlias, mnPath);
  +                    
  +						// we need two Joins for m:n
  +						// 1.) prev class to indirectionTable
  +						prevKeys = prev.cld.getPkFields();
  +						join = new Join(prev, prevKeys, indirect, cod.getFksToThisClass(), outer, attr +
"*");
  +						prev.addJoin(join);
  +                    }					
  +                    // 2.) indirectionTable to the current Class
  +					prev = indirect;
  +					prevKeys = cod.getFksToItemClass();
  +					keys = cld.getPkFields();
                   }
               }
               else
  
  
  

Mime
View raw message