Author: arminw
Date: Thu Jan  4 18:30:35 2007
New Revision: 492866

URL: http://svn.apache.org/viewvc?view=rev&rev=492866
Log:
add new methods to enable "select ... for update" and to append user-defined 
strings at the end of the query-string

Modified:
    
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/QueryByIdentity.java

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=492866&r1=492865&r2=492866
==============================================================================
--- 
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
 Thu Jan  4 18:30:35 2007
@@ -37,6 +37,8 @@
     protected Class m_searchClass;
     protected Class m_baseClass;
     private boolean m_withExtents = true;
+    private boolean selectForUpdate;
+    private String postfix;
 
     public AbstractQueryImpl()
     {
@@ -178,12 +180,31 @@
         return fetchSize;
     }
 
+    public boolean isSelectForUpdate()
+    {
+        return selectForUpdate;
+    }
+
+    public void setSelectForUpdate(boolean forUpdate)
+    {
+        this.selectForUpdate = forUpdate;
+    }
+
+    public String getQueryAffix()
+    {
+        return postfix;
+    }
+
+    public void setQueryAffix(String postfix)
+    {
+        this.postfix = postfix;
+    }
+
     /**
      * @see 
org.apache.ojb.broker.query.Query#preprocess(org.apache.ojb.broker.PersistenceBrokerInternal)
      */
     public void preprocess(PersistenceBrokerInternal aPb)
     {
-        // do nothing 
     }
 
 }

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=492866&r1=492865&r2=492866
==============================================================================
--- 
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 
Thu Jan  4 18:30:35 2007
@@ -138,7 +138,6 @@
     void fullSize(int size);
     /**
      * @deprecated use OJBIterator.fullSize()
-     * @return
      */
     int fullSize();
 
@@ -146,8 +145,7 @@
     boolean getWithExtents();
     
     /**
-     * Answer true if start- and endIndex is set
-     * @return
+     * Answer true if start- and endIndex is set.
      */
     public boolean usePaging();
 
@@ -165,6 +163,35 @@
      * (or 0 if not set / using driver default)
      */
     int getFetchSize();
+
+    /**
+     * Returns <em>true</em> if a "select .... for update" is enabled
+     * to lock the result set rows by the database.
+     */
+    boolean isSelectForUpdate();
+
+    /**
+     * Set <em>true</em> if a "select ... for update" database
+     * lock should be used (OJB will append the 'FOR UPDATE' expression
+     * at the end of the query string). By default it's disabled.
+     */
+    void setSelectForUpdate(boolean forUpdate);
+
+    /**
+     * Set an affix at the end of the query string.
+     *
+     * @param affix The affix string to append at the end of the query string.
+     */
+    void setQueryAffix(String affix);
+
+    /**
+     * Returns the affix string (By default no affix is set, so this method
+     * returns <em>null</em>).
+     *
+     * @return The query affix string or <em>null</em> if not set.
+     * @see #setQueryAffix(String) 
+     */
+    String getQueryAffix();
 
     /**
      * Preprocess the Query using a PersistenceBroker.

Modified: 
db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/query/QueryByIdentity.java
URL: 
http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/query/QueryByIdentity.java?view=diff&rev=492866&r1=492865&r2=492866
==============================================================================
--- 
db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/query/QueryByIdentity.java
 (original)
+++ 
db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/query/QueryByIdentity.java
 Thu Jan  4 18:30:35 2007
@@ -98,4 +98,24 @@
                }
        }
 
+    public void setQueryAffix(String postfix)
+    {
+        if(m_exampleObjectOrIdentity instanceof Identity)
+        {
+           throw new UnsupportedOperationException(
+                   "Method #setQueryAffix is not supported when using query 
objects of class ...ojb.broker.Identity");
+        }
+        super.setQueryAffix(postfix);
+    }
+
+    public void setSelectForUpdate(boolean forUpdate)
+    {
+        if(m_exampleObjectOrIdentity instanceof Identity)
+        {
+           throw new UnsupportedOperationException(
+                   "Method #setSelectForUpdate is not supported when using 
query objects of class ...ojb.broker.Identity"); 
+        }
+        super.setSelectForUpdate(forUpdate);
+    }
+
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to