db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject svn commit: r524320 - in /db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker: ./ accesslayer/ core/ query/
Date Fri, 30 Mar 2007 23:14:00 GMT
Author: arminw
Date: Fri Mar 30 16:14:00 2007
New Revision: 524320

URL: http://svn.apache.org/viewvc?view=rev&rev=524320
Log:
introduce new method Query.hasPrefetchedRelationships()

Modified:
    db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/IdentityFactory.java
    db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/accesslayer/JdbcAccessImpl.java
    db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/accesslayer/RsIterator.java
    db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/core/IdentityFactoryImpl.java
    db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/query/AbstractQueryImpl.java
    db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/query/Query.java
    db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/query/QueryByCriteria.java

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/IdentityFactory.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/IdentityFactory.java?view=diff&rev=524320&r1=524319&r2=524320
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/IdentityFactory.java (original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/IdentityFactory.java Fri
Mar 30 16:14:00 2007
@@ -76,23 +76,25 @@
      * Convenience shortcut method for
      * {@link #buildIdentity(java.lang.Class, java.lang.Class, java.lang.String[], java.lang.Object[])}.
      * 
-     * @param realClass     The class of the associated object
+     * @param clazz The class of the persistent object we look for. This can be an interface,
+     * abstract base class or the real implementation class.
      * @param pkFieldName   The field names of the PK fields
      * @param pkValues      The PK values
      * @return The new <em>Identity</em> object
      */
-    Identity buildIdentity(Class realClass, String[] pkFieldName, Object[] pkValues);
+    Identity buildIdentity(Class clazz, String[] pkFieldName, Object[] pkValues);
 
     /**
      * Convenience method for persistent objects with single primary key.
      * NOTE: Do not use for objects with composed PK!
      *
-     * @param realClass The class of the associated object
-     * @param pkValue   The PK value
+     * @param clazz The class of the persistent object we look for. This can be an interface,
+     * abstract base class or the real implementation class.
+     * @param pkValue   The primary key value.
      * @return The new <em>Identity</em> object
      * @see #buildIdentity(java.lang.Class, java.lang.String[], java.lang.Object[])
      */
-    Identity buildIdentity(Class realClass, Object pkValue);
+    Identity buildIdentity(Class clazz, Object pkValue);
 
     /**
      * Create a new {@link Identity} object based on given arguments - NOTE: There

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/accesslayer/JdbcAccessImpl.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/accesslayer/JdbcAccessImpl.java?view=diff&rev=524320&r1=524319&r2=524320
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/accesslayer/JdbcAccessImpl.java
(original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/accesslayer/JdbcAccessImpl.java
Fri Mar 30 16:14:00 2007
@@ -24,6 +24,7 @@
 import java.util.Iterator;
 import java.util.Map;
 
+import org.apache.commons.lang.ArrayUtils;
 import org.apache.ojb.broker.Identity;
 import org.apache.ojb.broker.OptimisticLockException;
 import org.apache.ojb.broker.PersistenceBrokerException;
@@ -44,7 +45,6 @@
 import org.apache.ojb.broker.util.logging.Logger;
 import org.apache.ojb.broker.util.logging.LoggerFactory;
 import org.apache.ojb.broker.util.sequence.SequenceManagerException;
-import org.apache.commons.lang.ArrayUtils;
 
 /**
  * JdbcAccess is responsible for establishing performing SQL Queries against remote
@@ -263,17 +263,14 @@
         query.preprocess(broker);
 
         /*
-		 * MBAIRD: we should create a scrollable resultset if the start at
-		 * index or end at index is set
-		 */
-        boolean scrollable = ((query.getStartAtIndex() > Query.NO_START_AT_INDEX) || (query.getEndAtIndex()
> Query.NO_END_AT_INDEX));
-        /*
-		 * OR if the prefetching of relationships is being used.
+		  MBAIRD: we should create a scrollable resultset if the start at
+		  index or end at index is set
+		  OR if the prefetching of relationships is being used.
 		 */
-        if (query != null && query.getPrefetchedRelationships() != null &&
!query.getPrefetchedRelationships().isEmpty())
-        {
-            scrollable = true;
-        }
+        boolean scrollable = (query.getStartAtIndex() > Query.NO_START_AT_INDEX)
+                || (query.getEndAtIndex() > Query.NO_END_AT_INDEX)
+                || query.hasPrefetchedRelationships();
+
         final StatementManagerIF sm = broker.serviceStatementManager();
         final SelectStatement sql = broker.serviceSqlGenerator().getPreparedSelectStatement(query,
cld);
         PreparedStatement stmt = null;

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/accesslayer/RsIterator.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/accesslayer/RsIterator.java?view=diff&rev=524320&r1=524319&r2=524320
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/accesslayer/RsIterator.java
(original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/accesslayer/RsIterator.java
Fri Mar 30 16:14:00 2007
@@ -340,7 +340,7 @@
         String relName;
         RelationshipPrefetcher[] prefetchers;
 
-        if (query == null || query.getPrefetchedRelationships() == null || query.getPrefetchedRelationships().isEmpty())
+        if (query == null || !query.hasPrefetchedRelationships())
         {
             return;
         }

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/core/IdentityFactoryImpl.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/core/IdentityFactoryImpl.java?view=diff&rev=524320&r1=524319&r2=524320
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/core/IdentityFactoryImpl.java
(original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/core/IdentityFactoryImpl.java
Fri Mar 30 16:14:00 2007
@@ -20,6 +20,7 @@
 import org.apache.commons.collections.map.ReferenceIdentityMap;
 import org.apache.commons.lang.ArrayUtils;
 import org.apache.commons.lang.SystemUtils;
+import org.apache.commons.lang.StringUtils;
 import org.apache.commons.lang.exception.ExceptionUtils;
 import org.apache.ojb.broker.Identity;
 import org.apache.ojb.broker.IdentityFactory;
@@ -177,7 +178,12 @@
         else
         {
             // in other more complex cases we do several check
-            FieldDescriptor[] flds = broker.getClassDescriptor(realClass).getPkFields();
+            ClassDescriptor cld = broker.getClassDescriptor(realClass);
+            if(StringUtils.isEmpty(cld.getFullTableName()))
+            {
+                cld = cld.getRepository().findFirstConcreteClass(cld);
+            }
+            FieldDescriptor[] flds = cld.getPkFields();
             if(!isOrdered(flds, pkFieldNames))
             {
                 orderedPKValues = reorderFieldValues(flds, pkFieldNames, pkValues);
@@ -243,9 +249,9 @@
     }
 
     /** @see org.apache.ojb.broker.IdentityFactory#buildIdentity(Class, String[], Object[])
*/
-    public Identity buildIdentity(final Class realClass, final String[] pkFieldNames, final
Object[] pkValues)
+    public Identity buildIdentity(final Class clazz, final String[] pkFieldNames, final Object[]
pkValues)
     {
-        return buildIdentity(realClass, broker.getTopLevelClass(realClass), pkFieldNames,
pkValues);
+        return buildIdentity(clazz, broker.getTopLevelClass(clazz), pkFieldNames, pkValues);
     }
 
     /** @see org.apache.ojb.broker.IdentityFactory#buildIdentity(Class, String[], Object[])
*/
@@ -255,9 +261,9 @@
     }
 
     /** @see org.apache.ojb.broker.IdentityFactory#buildIdentity(Class, Object) */
-    public Identity buildIdentity(final Class realClass, final Object pkValue)
+    public Identity buildIdentity(final Class clazz, final Object pkValue)
     {
-        return buildIdentity(realClass, (String[]) null, new Object[]{pkValue});
+        return buildIdentity(clazz, (String[]) null, new Object[]{pkValue});
     }
 
     /**

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/query/AbstractQueryImpl.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/query/AbstractQueryImpl.java?view=diff&rev=524320&r1=524319&r2=524320
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/query/AbstractQueryImpl.java
(original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/query/AbstractQueryImpl.java
Fri Mar 30 16:14:00 2007
@@ -119,6 +119,11 @@
         return null;
     }
 
+    public boolean hasPrefetchedRelationships()
+    {
+        return false;
+    }
+
     public Criteria getCriteria()
     {
         return null;

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/query/Query.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/query/Query.java?view=diff&rev=524320&r1=524319&r2=524320
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/query/Query.java (original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/query/Query.java Fri Mar
30 16:14:00 2007
@@ -61,6 +61,13 @@
     public List getPrefetchedRelationships();
 
     /**
+     * Check for prefetched relationships.
+     *
+     * @return <tt>True</tt> if relationships marked for prefetching.
+     */
+    public boolean hasPrefetchedRelationships();
+
+    /**
      * Return the criteria of the query if present or <tt>null</tt>.
      */
     public Criteria getCriteria();

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/query/QueryByCriteria.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/query/QueryByCriteria.java?view=diff&rev=524320&r1=524319&r2=524320
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/query/QueryByCriteria.java
(original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/query/QueryByCriteria.java
Fri Mar 30 16:14:00 2007
@@ -491,11 +491,16 @@
         {
             temp.addAll(getCriteria().getPrefetchedRelationships());
         }
-
         return temp;
     }
 
-	/**
+    public boolean hasPrefetchedRelationships()
+    {
+        return m_prefetchedRelationships.size() > 0 ||
+                (getCriteria() != null && getCriteria().getPrefetchedRelationships().size()
> 0);
+    }
+
+    /**
      * Get a Collection containing all Paths having an Outer-Joins-Setting
      * @return a Collection containing the Paths (Strings)
 	 */



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