db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b..@apache.org
Subject svn commit: r374915 - in /db/ojb/branches/OJB_1_0_RELEASE/src: java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java test/org/apache/ojb/broker/InheritanceMultipleTableTest.java
Date Sat, 04 Feb 2006 19:55:53 GMT
Author: brj
Date: Sat Feb  4 11:55:44 2006
New Revision: 374915

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

Modified:
    db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java
    db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/InheritanceMultipleTableTest.java

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java
URL: http://svn.apache.org/viewcvs/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java?rev=374915&r1=374914&r2=374915&view=diff
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java
(original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java
Sat Feb  4 11:55:44 2006
@@ -307,25 +307,12 @@
         }
 
         m_attrToFld.put(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); 
@@ -349,11 +336,11 @@
      * @param anAttrName
      * @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)
@@ -376,26 +363,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;
                 }
             }
         }

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/InheritanceMultipleTableTest.java
URL: http://svn.apache.org/viewcvs/db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/InheritanceMultipleTableTest.java?rev=374915&r1=374914&r2=374915&view=diff
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/InheritanceMultipleTableTest.java
(original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/InheritanceMultipleTableTest.java
Sat Feb  4 11:55:44 2006
@@ -487,7 +487,10 @@
         Consortium con = (Consortium) broker.getObjectByIdentity(oidCon);
         assertNotNull(con);
         assertNotNull(con.getManagers());
-        assertEquals(2, con.getManagers().size());
+        assertEquals(consortium.getId(), con.getId());
+        assertEquals(consortium.getName(), con.getName());
+        assertEquals(consortium.getManagers().size(), con.getManagers().size());
+        
         broker.clearCache();
         Manager s1_new = (Manager) broker.getObjectByIdentity(oidSH);
         assertNotNull(s1_new.getConsortiumKey());
@@ -497,10 +500,14 @@
                 .addEqualTo("name", consortium.getName())
                 .addEqualTo("managers.executives.address.street", name + "_street_12")
                 .addEqualTo("managers.name", name + "_Manager");
-        Query q = QueryFactory.newQuery(Consortium.class, crit);
+        Query q = QueryFactory.newQuery(Consortium.class, crit, true);
         Collection result = broker.getCollectionByQuery(q);
         assertEquals(1, result.size());
-        assertEquals(consortium, result.iterator().next());
+        
+        Consortium con2 =  (Consortium) result.iterator().next();
+        assertEquals(consortium.getId(), con2.getId());
+        assertEquals(consortium.getName(), con2.getName());
+        assertEquals(consortium.getManagers().size(), con2.getManagers().size());
     }
 
 



---------------------------------------------------------------------
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