You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openjpa.apache.org by wi...@apache.org on 2007/03/27 22:47:22 UTC

svn commit: r523071 - in /incubator/openjpa/trunk: openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/ openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/ openjpa-kernel/src/main/java/org/apache/openjpa/kernel/ openjpa-persistence/src/main/j...

Author: wisneskid
Date: Tue Mar 27 13:47:21 2007
New Revision: 523071

URL: http://svn.apache.org/viewvc?view=rev&rev=523071
Log:
fixing indentation and few changes suggested by Abe for OpenJPA patch-168

Added:
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/QueryHints.java
Modified:
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCStoreManager.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCStoreQuery.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/LogicalUnion.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SelectExecutor.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SelectImpl.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractStoreQuery.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/QueryImpl.java
    incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAQuery.java
    incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/QueryImpl.java

Modified: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCStoreManager.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCStoreManager.java?view=diff&rev=523071&r1=523070&r2=523071
==============================================================================
--- incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCStoreManager.java (original)
+++ incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCStoreManager.java Tue Mar 27 13:47:21 2007
@@ -363,18 +363,18 @@
      * null if there is no data in the current fetch groups to select.
      */
     private Result getInitializeStateResult(OpenJPAStateManager sm,
-        ClassMapping mapping, JDBCFetchConfiguration fetch, int subs)
-        throws SQLException {
+            ClassMapping mapping, JDBCFetchConfiguration fetch, int subs)
+    throws SQLException {
         Select sel = _sql.newSelect();
         if (!select(sel, mapping, subs, sm, null, fetch,
-            JDBCFetchConfiguration.EAGER_JOIN, true, false))
+                JDBCFetchConfiguration.EAGER_JOIN, true, false))
             return null;
         sel.wherePrimaryKey(sm.getObjectId(), mapping, this);
-        //Set the expectedResultCount for the select as 1 as a single
-        //object is being loaded. force = true is an indicator that it is 
-        //internally generated value
-          sel.setExpectedResultCount(1,true);
-       return sel.execute(this, fetch);
+        // Set the expectedResultCount for the select as 1 as a single
+        // object is being loaded. force = true is an indicator that it is 
+        // internally generated value
+        sel.setExpectedResultCount(1,true);
+        return sel.execute(this, fetch);
     }
 
     /**

Modified: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCStoreQuery.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCStoreQuery.java?view=diff&rev=523071&r1=523070&r2=523071
==============================================================================
--- incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCStoreQuery.java (original)
+++ incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCStoreQuery.java Tue Mar 27 13:47:21 2007
@@ -48,6 +48,7 @@
 import org.apache.openjpa.jdbc.sql.Union;
 import org.apache.openjpa.kernel.ExpressionStoreQuery;
 import org.apache.openjpa.kernel.OrderingMergedResultObjectProvider;
+import org.apache.openjpa.kernel.QueryHints;
 import org.apache.openjpa.kernel.exps.ExpressionFactory;
 import org.apache.openjpa.kernel.exps.ExpressionParser;
 import org.apache.openjpa.kernel.exps.FilterListener;
@@ -319,23 +320,22 @@
                 subclassMode);
             if (verts.length == 1 && subclasses)
                 subclassBits.set(sels.size());
-
             // create criteria select and clone for each vert mapping
             sel = ((JDBCExpressionFactory) facts[i]).getSelectConstructor().
                 evaluate(ctx, null, null, exps[i], states[i]);
-            //it means it is coming from getSingleResult so set the 
-            //expectedResultCount to 1.force = true indicates that this is 
-            //internally generated value
-            if(this.ctx.isUnique())
-                 sel.setExpectedResultCount(1,true);
-            //it means this is coming from getResultList so set the 
-            //expectedResultCount based on any optimize hint if provided
-            else{
-                   if((optHint = ctx.fetch.getHint
-                        (this.optimizeHint))!= null)
-                         sel.setExpectedResultCount
-                          (((Integer)optHint).intValue(),false);
-               }
+            // It means it is coming from getSingleResult so set the 
+            // expectedResultCount to 1.force = true indicates that this is 
+            // internally generated value
+            if (this.ctx.isUnique())
+                sel.setExpectedResultCount(1,true);
+            // It means this is coming from getResultList so set the 
+            // expectedResultCount based on any optimize hint if provided
+            else {
+                if ((optHint = ctx.fetch.getHint
+                              (QueryHints.HINT_RESULT_COUNT))!= null)
+                   sel.setExpectedResultCount
+                   (((Integer)optHint).intValue(),false);
+            }
             for (int j = 0; j < verts.length; j++) {
                 selMappings.add(verts[j]);
                 if (j == verts.length - 1) {

Modified: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java?view=diff&rev=523071&r1=523070&r2=523071
==============================================================================
--- incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java (original)
+++ incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java Tue Mar 27 13:47:21 2007
@@ -28,8 +28,7 @@
  */
 public class DB2Dictionary
     extends AbstractDB2Dictionary {
-    
-    //variables to support optimize clause
+    // variables to support optimize clause
     public String optimizeClause = "optimize for";
     public String rowClause = "row";
     public DB2Dictionary() {
@@ -195,67 +194,63 @@
                     bigintTypeName = "DECIMAL(31,0)";
                 }
             }
-    	}
+        }
     }
-    //based on the expectedResultCount of the select create the optimize
-    //for clause
+    
+    /** Based on the expectedResultCount of the select create the optimize
+     *  for clause
+     */ 
     public String getOptimizeClause(JDBCFetchConfiguration fetch, 
-                                   int expectedResultCount) {
+            int expectedResultCount) {
         Integer rows = null;
         StringBuffer optimizeString = new StringBuffer();
-        
-        	if(expectedResultCount != 0)
-                optimizeString.append(" ").append(optimizeClause).append(" ")
-                .append(expectedResultCount).append(" ")
-                .append(rowClause).append(" ");
-           return optimizeString.toString();    
+        if (expectedResultCount != 0)
+            optimizeString.append(" ").append(optimizeClause).append(" ")
+            .append(expectedResultCount).append(" ")
+            .append(rowClause).append(" ");
+        return optimizeString.toString();    
     }
 
-    //override the DBDictionary toSelect to call getOptimizeClause and append 
-    //to the select string
+    /** Override the DBDictionary toSelect to call getOptimizeClause and append 
+    *   to the select string
+    */   
     public SQLBuffer toSelect(SQLBuffer selects, JDBCFetchConfiguration fetch,
             SQLBuffer from, SQLBuffer where, SQLBuffer group,
             SQLBuffer having, SQLBuffer order,
             boolean distinct, boolean forUpdate, long start, long end,
             int expectedResultCount) {
-        	
-        	String optimizeString = null;
-        	SQLBuffer selString = toOperation(getSelectOperation(fetch), 
-                                              selects, from, where,
-                                              group, having, order, distinct,
-                                              forUpdate, start, end);
-            //return toOperation(getSelectOperation(fetch), selects, from, where,
-             //group, having, order, distinct, forUpdate, start, end);
-        	
-        	if(fetch != null)
-        	    optimizeString = getOptimizeClause(fetch, expectedResultCount);
-        	if(optimizeString != null && optimizeString.length() > 0)
-        		selString.append(optimizeString);
-        	
-        	return selString;
-        	
-        }
-    //override the DBDictionary toSelect to pass expectedResultcount to the 
-    //other toSelect method
+        String optimizeString = null;
+        SQLBuffer selString = toOperation(getSelectOperation(fetch), 
+                selects, from, where,
+                group, having, order, distinct,
+                forUpdate, start, end);
+        if (fetch != null)
+            optimizeString = getOptimizeClause(fetch, expectedResultCount);
+        if (optimizeString != null && optimizeString.length() > 0)
+            selString.append(optimizeString);
+        return selString;
+    }
+    
+    /** Override the DBDictionary toSelect to pass expectedResultcount to the 
+     * other toSelect method
+     */
     public SQLBuffer toSelect(Select sel, boolean forUpdate,
             JDBCFetchConfiguration fetch) {
-            sel.addJoinClassConditions();
-            
-            boolean update = forUpdate && sel.getFromSelect() == null;
-            SQLBuffer select = getSelects(sel, false, update);
-            SQLBuffer ordering = null;
-            if (!sel.isAggregate() || sel.getGrouping() != null)
-                ordering = sel.getOrdering();
-            SQLBuffer from;
-            if (sel.getFromSelect() != null)
-                from = getFromSelect(sel, forUpdate);
-            else
-                from = getFrom(sel, update);
-            SQLBuffer where = getWhere(sel, update);
-            return toSelect(select, fetch, from, where, sel.getGrouping(),
+        sel.addJoinClassConditions();
+        boolean update = forUpdate && sel.getFromSelect() == null;
+        SQLBuffer select = getSelects(sel, false, update);
+        SQLBuffer ordering = null;
+        if (!sel.isAggregate() || sel.getGrouping() != null)
+            ordering = sel.getOrdering();
+        SQLBuffer from;
+        if (sel.getFromSelect() != null)
+            from = getFromSelect(sel, forUpdate);
+        else
+            from = getFrom(sel, update);
+        SQLBuffer where = getWhere(sel, update);
+        return toSelect(select, fetch, from, where, sel.getGrouping(),
                 sel.getHaving(), ordering, sel.isDistinct(), forUpdate,
                 sel.getStartIndex(), 
                 sel.getEndIndex(),sel.getExpectedResultCount());
-        }
-
+    }
 }

Modified: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/LogicalUnion.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/LogicalUnion.java?view=diff&rev=523071&r1=523070&r2=523071
==============================================================================
--- incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/LogicalUnion.java (original)
+++ incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/LogicalUnion.java Tue Mar 27 13:47:21 2007
@@ -47,11 +47,7 @@
 
     private static final Localizer _loc = Localizer.forPackage
         (LogicalUnion.class);
-     //expected number of results for this select to be used in 
-    // optimize for clause
     protected int expectedResultCount = 0;
-    //indicate if this is internally generated result count 
-    //or not
     protected boolean force = false;
     protected final UnionSelect[] sels;
     protected final DBDictionary dict;
@@ -215,9 +211,10 @@
         if (this.getExpectedResultCount()== 1) {
             AbstractResult res;
             for (int i = 0; i < sels.length; i++) {
-                //for each select set the expected result count to 1
-                //and force true indicating that this internally generated value
-                 sels[i].sel.setExpectedResultCount(1,true);
+                // For each select set the expected result count to 1
+                // and force true indicating that this internally generated 
+                // value
+                sels[i].sel.setExpectedResultCount(1,true);
                 res = (AbstractResult) sels[i].execute(store, fetch,
                     lockLevel);
                 res.setBaseMapping(mappings[i]);
@@ -305,10 +302,7 @@
         protected final int pos;
         protected int orders = 0;
         protected List orderIdxs = null;
-        //  expected number of results for this select to be used in 
-        // optimize for clause
         protected int expectedResultCount = 0;
-        //force indicates it is internally generated result count or not
         protected boolean force = false;
        
         public UnionSelect(SelectImpl sel, int pos) {
@@ -844,17 +838,19 @@
             return sel.toString();
         }
 
-		public int getExpectedResultCount() {
-			return expectedResultCount;
-		}
+        public int getExpectedResultCount() {
+            return expectedResultCount;
+        }
 
-		public void setExpectedResultCount(int expectedResultCount, boolean force) {
-			this.expectedResultCount = expectedResultCount;
+        public void setExpectedResultCount(int expectedResultCount,
+                boolean force) {
+            this.expectedResultCount = expectedResultCount;
             this.force = force;
-		}
-         public boolean isExpRsltCntForced() {
-                return force;
-            }
+        }
+        
+        public boolean isExpRsltCntForced() {
+            return force;
+        }
     }
 
     /**
@@ -939,11 +935,13 @@
     public int getExpectedResultCount() {
         return expectedResultCount;
     }
-
-    public void setExpectedResultCount(int expectedResultCount,boolean force) {
+    
+    public void setExpectedResultCount(int expectedResultCount,
+            boolean force) {
         this.expectedResultCount = expectedResultCount;
         this.force = force;
     }
+    
     public boolean isExpRsltCntForced() {
         return force;
     }

Modified: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SelectExecutor.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SelectExecutor.java?view=diff&rev=523071&r1=523070&r2=523071
==============================================================================
--- incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SelectExecutor.java (original)
+++ incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SelectExecutor.java Tue Mar 27 13:47:21 2007
@@ -130,12 +130,10 @@
      * force indicates whether the count is internally generated
      * or given by the user as optimize hint
      */
-    
     public void setExpectedResultCount(int expectedResultCount,boolean force) ;
-    
+
     /**
      * Indicates whether the expectedResultCount is internally generated
      */
-     
-     public boolean isExpRsltCntForced();
+    public boolean isExpRsltCntForced();
 }

Modified: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SelectImpl.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SelectImpl.java?view=diff&rev=523071&r1=523070&r2=523071
==============================================================================
--- incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SelectImpl.java (original)
+++ incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SelectImpl.java Tue Mar 27 13:47:21 2007
@@ -154,11 +154,7 @@
     private SelectImpl _from = null;
     private SelectImpl _outer = null;
     
-    //expected number of results for this select to be used in 
-    // optimize for clause
     private int expectedResultCount = 0;
-    //true if the expectedResultCount is internally set false if
-    //it is set by the user
     private boolean force = false;
      
     /**
@@ -312,19 +308,19 @@
         throws SQLException {
         boolean forUpdate = false;
         
-        //expectedResultCount = 1 and force means that it is internally generated value 
-        //for getSingleResult,single valued relationship.We need to check if 
-        //there are any eager joins in the select if there are then the 
-        //optimize for 1 row clause is not generated else we do. if 
-        //!force then it is set by the user through hint and we 
-        //do not check the eager joins
-        if(this.expectedResultCount == 1 && force ){
-            if(this.hasEagerJoin(true))
+        // ExpectedResultCount = 1 and force means that it is internally  
+        // generated value for getSingleResult,single valued relationship. 
+        // We need to check if there are any eager joins in the select if  
+        // there are then the optimize for 1 row clause is not generated  
+        // else we do. if !force then it is set by the user through hint  
+        // and we do not check the eager joins
+        if (this.expectedResultCount == 1 && force ) {
+            if (this.hasEagerJoin(true))
                 this.setExpectedResultCount(0,false);
             else
-               this.setExpectedResultCount(1,false); 
-           }
-      
+                this.setExpectedResultCount(1,false); 
+        }
+
         if (!isAggregate() && _grouping == null) {
             JDBCLockManager lm = store.getLockManager();
             if (lm != null)
@@ -2821,14 +2817,15 @@
         }
     }
 
-	public int getExpectedResultCount() {
-		return expectedResultCount;
-	}
+    public int getExpectedResultCount() {
+        return expectedResultCount;
+    }
 
-	public void setExpectedResultCount(int expectedResultCount, boolean force) {
-		this.expectedResultCount = expectedResultCount;
+    public void setExpectedResultCount(int expectedResultCount,
+            boolean force) {
+        this.expectedResultCount = expectedResultCount;
         this.force = force;
-	}
+    }
 
     public boolean isExpRsltCntForced() {
         return force;

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractStoreQuery.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractStoreQuery.java?view=diff&rev=523071&r1=523070&r2=523071
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractStoreQuery.java (original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractStoreQuery.java Tue Mar 27 13:47:21 2007
@@ -33,8 +33,7 @@
     implements StoreQuery {
 
     protected QueryContext ctx = null;
-    public static final String optimizeHint ="openjpa.hint.OptimizeResultCount";
-
+   
     public QueryContext getContext() {
         return ctx;
     }

Added: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/QueryHints.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/QueryHints.java?view=auto&rev=523071
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/QueryHints.java (added)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/QueryHints.java Tue Mar 27 13:47:21 2007
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.openjpa.kernel;
+
+public interface QueryHints {
+    
+    /** Hint to specify the number of rows for the optimize
+     * clause for DB2
+     */
+    public static final String HINT_RESULT_COUNT =
+        "openjpa.hint.OptimizeResultCount";
+}

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/QueryImpl.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/QueryImpl.java?view=diff&rev=523071&r1=523070&r2=523071
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/QueryImpl.java (original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/QueryImpl.java Tue Mar 27 13:47:21 2007
@@ -1290,7 +1290,7 @@
                 return Arrays.asList(new Object[]{ single });
             }
              
-            if(single == null)
+            if (single == null)
                 throw new InvalidStateException(_loc.get("is-null",
                         _class, _query));
             

Modified: incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAQuery.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAQuery.java?view=diff&rev=523071&r1=523070&r2=523071
==============================================================================
--- incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAQuery.java (original)
+++ incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAQuery.java Tue Mar 27 13:47:21 2007
@@ -24,6 +24,7 @@
 import javax.persistence.TemporalType;
 
 import org.apache.openjpa.kernel.QueryFlushModes;
+import org.apache.openjpa.kernel.QueryHints;
 import org.apache.openjpa.kernel.QueryOperations;
 import org.apache.openjpa.kernel.exps.AggregateListener;
 import org.apache.openjpa.kernel.exps.FilterListener;
@@ -36,7 +37,7 @@
  * @published
  */
 public interface OpenJPAQuery
-    extends Query, QueryOperations, QueryFlushModes {
+    extends Query, QueryOperations, QueryFlushModes, QueryHints {
 
     /**
      * The owning entity manage.

Modified: incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/QueryImpl.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/QueryImpl.java?view=diff&rev=523071&r1=523070&r2=523071
==============================================================================
--- incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/QueryImpl.java (original)
+++ incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/QueryImpl.java Tue Mar 27 13:47:21 2007
@@ -279,13 +279,12 @@
      */
     public Object getSingleResult() {
         _em.assertNotCloseInvoked();
-        //Indicate that this query returns single result.Later copied into
-        //select.expectedResultCount
+        // Indicate that this query returns single result.Later copied into
+        // select.expectedResultCount
         _query.setUnique(true);
-        try{
-        Object ob = execute();
-           return ob;
-
+        try {
+            Object ob = execute();
+            return ob;
         } finally {
             _query.setUnique(false);
         }
@@ -366,27 +365,29 @@
             } else if (k.startsWith("FetchPlan.")) {
                 k = k.substring("FetchPlan.".length());
                 Filters.hintToSetter(getFetchPlan(), k, value);
-            } else if (k.startsWith("hint.")){
-            	if("hint.OptimizeResultCount".equals(k)){
-            		if((!(value instanceof String)&&!(value instanceof Integer))
-                       ||  (value instanceof String &&(Integer.parseInt
-                       ((String)value)< 0))||((value instanceof Integer)
-                        && (((Integer)value).intValue()<0)) )
-            			    throw new ArgumentException(_loc.get
-                                      ("bad-hint-value", key),
-                                      null, null, false);
-                    if(value instanceof String)
+            } else if (k.startsWith("hint.")) {
+                if ("hint.OptimizeResultCount".equals(k)) {
+                    if ((!(value instanceof String)&&! (value instanceof Integer))
+                            || (value instanceof String &&(Integer.parseInt
+                                    ((String)value)< 0))||
+                                    ((value instanceof Integer)
+                                            && (((Integer)value).intValue()<0)))
+                        throw new ArgumentException(_loc.get
+                                ("bad-hint-value", key),
+                                null, null, false);
+                    if (value instanceof String)
                         value = new Integer((String)value);
-         	}
+                }
                 _query.getFetchConfiguration().setHint(key, value);
             }
             else
                 throw new ArgumentException(_loc.get("bad-query-hint", key),
                     null, null, false);
             return this;
-        }catch(NumberFormatException e1){
-              throw new ArgumentException(_loc.get("bad-hint-value", key),
-                null, null, false); 
+        }
+         catch (NumberFormatException e1) {
+            throw new ArgumentException(_loc.get("bad-hint-value", key),
+                    null, null, false); 
         }
          catch (Exception e) {
             throw PersistenceExceptions.toPersistenceException(e);