db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b..@apache.org
Subject svn commit: r374916 - /db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java
Date Sat, 04 Feb 2006 20:03:40 GMT
Author: brj
Date: Sat Feb  4 12:03:37 2006
New Revision: 374916

URL: http://svn.apache.org/viewcvs?rev=374916&view=rev
Log:
fix for ojb-94

Modified:
    db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java

Modified: db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java
URL: http://svn.apache.org/viewcvs/db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java?rev=374916&r1=374915&r2=374916&view=diff
==============================================================================
--- db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java (original)
+++ db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java Sat
Feb  4 12:03:37 2006
@@ -292,25 +292,12 @@
         }
 
         setFieldDescriptorForAttribute(anAttrInfo.getParent().getAttribute(), fld);
-
-        // added to suport the super reference descriptor
-        if (!fld.getClassDescriptor().getFullTableName().equals(tableAlias.table) &&
tableAlias.hasJoins())
-        {
-            Iterator itr = tableAlias.joins.iterator();
-            while (itr.hasNext())
-            {
-                Join join = (Join) itr.next();
-                if (join.right.table.equals(fld.getClassDescriptor().getFullTableName()))
-                {
-                    tableAlias = join.right;
-                    colName = fld.getColumnName();
-                    break;
-                }
-            }
-        }
-        else
+        colName = fld.getColumnName();
+                
+        // added to support the super reference descriptor,  use the corresponding tableAlias

+        if (!fld.getClassDescriptor().equals(tableAlias.cld) && tableAlias.hasJoins())
         {
-            colName = fld.getColumnName();
+            tableAlias = getTableAliasForClassDescriptor(fld.getClassDescriptor());
         }
 
         appendColumn(tableAlias, colName, buf);
@@ -354,11 +341,11 @@
      * @param anAttrName the name of the attribute
      * @return FieldDescriptor
      */
-    protected FieldDescriptor getFieldDescriptor(TableAlias aTableAlias, String anAttrName)
+    private FieldDescriptor getFieldDescriptor(TableAlias aTableAlias, String anAttrName)
     {
         FieldDescriptor fld = null;
 
-        if (aTableAlias != null)
+        if (aTableAlias != null && aTableAlias.cld != null)
         {
             fld = aTableAlias.cld.getFieldDescriptorByName(anAttrName);
             if (fld == null)
@@ -381,26 +368,25 @@
     /**
      * Get FieldDescriptor from joined superclass.
      */
-    private FieldDescriptor getFldFromJoin(TableAlias aTableAlias, String aColName)
+    private FieldDescriptor getFldFromJoin(TableAlias aTableAlias, String attrName)
     {
         FieldDescriptor fld = null;
 
         // Search Join Structure for attribute
+        // TODO BRJ: imo we have to consider 'superClass' joins only
         if (aTableAlias.joins != null)
         {
             Iterator itr = aTableAlias.joins.iterator();
             while (itr.hasNext())
             {
                 Join join = (Join) itr.next();
-                ClassDescriptor cld = join.right.cld;
-
-                if (cld != null)
+                if ("superClass".equals(join.name))
                 {
-                    fld = cld.getFieldDescriptorByName(aColName);
-                    if (fld != null)
-                    {
-                        break;
-                    }
+                    fld = getFieldDescriptor(join.right, attrName);
+                }
+                if (fld != null)
+                {
+                    break;
                 }
             }
         }



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


Mime
View raw message