You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-dev@db.apache.org by ar...@apache.org on 2007/03/02 01:58:57 UTC
svn commit: r513569 [2/2] - in
/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker: ./
accesslayer/ accesslayer/sql/ core/ metadata/ platforms/ query/
Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/platforms/PlatformOracleImpl.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/platforms/PlatformOracleImpl.java?view=diff&rev=513569&r1=513568&r2=513569
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/platforms/PlatformOracleImpl.java (original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/platforms/PlatformOracleImpl.java Thu Mar 1 16:58:55 2007
@@ -34,6 +34,7 @@
import org.apache.commons.lang.SerializationUtils;
import org.apache.ojb.broker.PersistenceBrokerSQLException;
+import org.apache.ojb.broker.query.Query;
import org.apache.ojb.broker.metadata.FieldDescriptor;
import org.apache.ojb.broker.metadata.JdbcConnectionDescriptor;
import org.apache.ojb.broker.util.ClassHelper;
@@ -58,78 +59,78 @@
*
* <table cellspacing="2" cellpadding="2" border="3" frame="box">
* <tr>
- * <td><strong>Property Key</strong></td>
- * <td><strong>Property Values</strong></td>
+ * <td><strong>Property Key</strong></td>
+ * <td><strong>Property Values</strong></td>
* </tr>
* <tr>
- * <td>sequenceStart</td>
- * <td>
- * DEPRECATED. Database sequence specific property.<br/>
- * Specifies the first sequence number to be
- * generated. Allowed: <em>1</em> or greater.
- * </td>
+ * <td>sequenceStart</td>
+ * <td>
+ * DEPRECATED. Database sequence specific property.<br/>
+ * Specifies the first sequence number to be
+ * generated. Allowed: <em>1</em> or greater.
+ * </td>
* </tr>
* <tr>
- * <td>seq.start</td>
- * <td>
- * Database sequence specific property.<br/>
- * Specifies the first sequence number to be
- * generated. Allowed: <em>1</em> or greater.
- * </td>
+ * <td>seq.start</td>
+ * <td>
+ * Database sequence specific property.<br/>
+ * Specifies the first sequence number to be
+ * generated. Allowed: <em>1</em> or greater.
+ * </td>
* </tr>
* <tr>
- * <td>seq.incrementBy</td>
- * <td>
- * Database sequence specific property.<br/>
- * Specifies the interval between sequence numbers.
- * This value can be any positive or negative
- * integer, but it cannot be 0.
- * </td>
+ * <td>seq.incrementBy</td>
+ * <td>
+ * Database sequence specific property.<br/>
+ * Specifies the interval between sequence numbers.
+ * This value can be any positive or negative
+ * integer, but it cannot be 0.
+ * </td>
* </tr>
* <tr>
- * <td>seq.maxValue</td>
- * <td>
- * Database sequence specific property.<br/>
- * Set max value for sequence numbers.
- * </td>
+ * <td>seq.maxValue</td>
+ * <td>
+ * Database sequence specific property.<br/>
+ * Set max value for sequence numbers.
+ * </td>
* </tr>
* <tr>
- * <td>seq.minValue</td>
- * <td>
- * Database sequence specific property.<br/>
- * Set min value for sequence numbers.
- * </td>
+ * <td>seq.minValue</td>
+ * <td>
+ * Database sequence specific property.<br/>
+ * Set min value for sequence numbers.
+ * </td>
* </tr>
* <tr>
- * <td>seq.cycle</td>
- * <td>
- * Database sequence specific property.<br/>
- * If <em>true</em>, specifies that the sequence continues to generate
- * values after reaching either its maximum or minimum value.
- * <br/>
- * If <em>false</em>, specifies that the sequence cannot generate more values after
- * reaching its maximum or minimum value.
- * </td>
+ * <td>seq.cycle</td>
+ * <td>
+ * Database sequence specific property.<br/>
+ * If <em>true</em>, specifies that the sequence continues to generate
+ * values after reaching either its maximum or minimum value.
+ * <br/>
+ * If <em>false</em>, specifies that the sequence cannot generate more values after
+ * reaching its maximum or minimum value.
+ * </td>
* </tr>
* <tr>
- * <td>seq.cache</td>
- * <td>
- * Database sequence specific property.<br/>
- * Specifies how many values of the sequence Oracle
- * preallocates and keeps in memory for faster access.
- * Allowed values: <em>2</em> or greater. If set <em>0</em>,
- * an explicite <em>nocache</em> expression will be set.
- * </td>
+ * <td>seq.cache</td>
+ * <td>
+ * Database sequence specific property.<br/>
+ * Specifies how many values of the sequence Oracle
+ * preallocates and keeps in memory for faster access.
+ * Allowed values: <em>2</em> or greater. If set <em>0</em>,
+ * an explicite <em>nocache</em> expression will be set.
+ * </td>
* </tr>
* <tr>
- * <td>seq.order</td>
- * <td>
- * Database sequence specific property.<br/>
- * If set <em>true</em>, guarantees that sequence numbers
- * are generated in order of request.
- * <br/>
- * If <em>false</em>, a <em>no order</em> expression will be set.
- * </td>
+ * <td>seq.order</td>
+ * <td>
+ * Database sequence specific property.<br/>
+ * If set <em>true</em>, guarantees that sequence numbers
+ * are generated in order of request.
+ * <br/>
+ * If <em>false</em>, a <em>no order</em> expression will be set.
+ * </td>
* </tr>
* </table>
*
@@ -142,6 +143,7 @@
/**
* Field value of <code>oracle.jdbc.OracleTypes.CURSOR</code>.
+ *
* @see #initOracleReflectedVars
*/
protected int ORACLE_JDBC_TYPE_CURSOR = -10;
@@ -166,15 +168,15 @@
final Field cursorField = oracleTypes.getField("CURSOR");
ORACLE_JDBC_TYPE_CURSOR = cursorField.getInt(null);
}
- catch (ClassNotFoundException e)
+ catch(ClassNotFoundException e)
{
log.warn("PlatformOracleImpl could not find Oracle JDBC classes");
}
- catch (NoSuchFieldException e)
+ catch(NoSuchFieldException e)
{
log.warn("PlatformOracleImpl could not find Oracle JDBC type fields");
}
- catch (IllegalAccessException e)
+ catch(IllegalAccessException e)
{
log.warn("PlatformOracleImpl could not get Oracle JDBC type values");
}
@@ -183,7 +185,8 @@
/**
* Method prepareNextValProcedureStatement implementation
* is simply copied over from PlatformMsSQLServerImpl class.
- * @see org.apache.ojb.broker.platforms.Platform#prepareNextValProcedureStatement(java.sql.Connection, java.lang.String, java.lang.String)
+ *
+ * @see Platform#prepareNextValProcedureStatement(java.sql.Connection, String, String)
*/
public CallableStatement prepareNextValProcedureStatement(Connection con, String procedureName, String sequenceName)
throws PlatformException
@@ -196,7 +199,7 @@
cs.setString(2, sequenceName);
return cs;
}
- catch (SQLException e)
+ catch(SQLException e)
{
throw new PlatformException(e);
}
@@ -211,7 +214,7 @@
{
stmt.setEscapeProcessing(true);
}
- catch (SQLException e)
+ catch(SQLException e)
{
throw new PlatformException("Could not set escape processing", e);
}
@@ -228,9 +231,9 @@
public void setObjectForStatement(PreparedStatement ps, int index, Object value, int sqlType)
throws SQLException
{
- if ((sqlType == Types.VARCHAR || sqlType == Types.CHAR) && (value instanceof String || value instanceof Character))
+ if((sqlType == Types.VARCHAR || sqlType == Types.CHAR) && (value instanceof String || value instanceof Character))
{
- if (value instanceof String)
+ if(value instanceof String)
{
ps.setString(index, (String) value);
}
@@ -239,30 +242,30 @@
ps.setString(index, value.toString());
}
}
- else if (value instanceof Double)
+ else if(value instanceof Double)
{
// workaround for the bug in Oracle thin driver
ps.setDouble(index, ((Double) value).doubleValue());
}
- else if (sqlType == Types.BIGINT && value instanceof Integer)
+ else if(sqlType == Types.BIGINT && value instanceof Integer)
{
// workaround: Oracle thin driver problem when expecting long
ps.setLong(index, ((Integer) value).intValue());
}
- else if (sqlType == Types.INTEGER && value instanceof Long)
+ else if(sqlType == Types.INTEGER && value instanceof Long)
{
ps.setLong(index, ((Long) value).longValue());
}
- else if (sqlType == Types.DATE && value instanceof String)
+ else if(sqlType == Types.DATE && value instanceof String)
{
// special handling of like for dates (birthDate like '2000-01%')
ps.setString(index, (String) value);
}
- else if (sqlType == Types.CLOB && (value instanceof String || value instanceof byte[]))
+ else if(sqlType == Types.CLOB && (value instanceof String || value instanceof byte[]))
{
Reader reader;
int length;
- if (value instanceof String)
+ if(value instanceof String)
{
String stringValue = (String) value;
length = stringValue.length();
@@ -277,7 +280,8 @@
}
ps.setCharacterStream(index, reader, length);
}
- else if ((value instanceof byte[]) && ((sqlType == Types.VARBINARY) || (sqlType == Types.LONGVARBINARY) || (sqlType == Types.BLOB)))
+ else
+ if((value instanceof byte[]) && ((sqlType == Types.VARBINARY) || (sqlType == Types.LONGVARBINARY) || (sqlType == Types.BLOB)))
{
// byte buf[] = (byte[]) value;
// int length = buf.length;
@@ -347,7 +351,7 @@
f.setInt(ps, 1);
f.setAccessible(false);
}
- catch (Exception e)
+ catch(Exception e)
{
logger.info("Not using classes12.zip.");
}
@@ -456,34 +460,65 @@
stmt.registerOutParameter(position, ORACLE_JDBC_TYPE_CURSOR);
}
-// /**
-// * Checks if the supplied connection is using the Oracle thin driver.
-// *
-// * @param conn database connection for which to check JDBC-driver
-// * @return <code>true</code> if the connection is using Oracle thin driver, <code>false</code>
-// * otherwise.
-// */
-// protected static boolean isUsingOracleThinDriver(Connection conn)
-// {
-// if (conn == null)
-// {
-// return false;
-// }
-// final DatabaseMetaData dbMetaData;
-// final String dbUrl;
-// try
-// {
-// dbMetaData = conn.getMetaData();
-// dbUrl = dbMetaData.getURL();
-// if (dbUrl != null && dbUrl.startsWith(THIN_URL_PREFIX))
-// {
-// return true;
-// }
-// }
-// catch (Exception e)
-// {
-// // ignore it
-// }
-// return false;
-// }
+ public boolean supportsLimit()
+ {
+ return true;
+ }
+
+ public boolean supportsOffset()
+ {
+ return true;
+ }
+
+ public StringBuffer addLimitSql(Query query, StringBuffer anSqlString)
+ {
+ StringBuffer tmp = new StringBuffer("select * from ( ");
+ tmp.append(anSqlString.toString());
+ tmp.append(" ) a where rownum <= ?");
+ return tmp;
+ }
+
+ public StringBuffer addPagingSql(Query query, StringBuffer anSqlString)
+ {
+ /*
+ See http://asktom.oracle.com/pls/asktom/f?p=100:11:1115003470206423::::P11_QUESTION_ID:127412348064
+ select *
+ from ( select a.*, rownum rnum
+ from ( YOUR_QUERY_GOES_HERE -- including the order by )
+ a where rownum <= MAX_ROWS ) where rnum >= MIN_ROWS
+ */
+ StringBuffer tmp = new StringBuffer("SELECT * FROM ( SELECT foo_.*, rownum rnum_ FROM ( ");
+ tmp.append(anSqlString.toString());
+ tmp.append(" ) foo_ WHERE rownum <= ? ) WHERE rnum_ >= ?");
+ return tmp;
+ }
+
+ public boolean limitAfterSelect()
+ {
+ return false;
+ }
+
+ public boolean limitBeforeOffset()
+ {
+ return true;
+ }
+
+ public int buildLimit(Query query)
+ {
+ int result = 0;
+ if(query.hasLimit())
+ {
+ return query.getEndAtIndex();
+ }
+ else if(query.hasOffset())
+ {
+ return MAX_LIMIT_VALUE;
+ }
+ return result;
+ }
+
+ public int buildOffset(Query query)
+ {
+ return query.getStartAtIndex();
+ }
}
Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/platforms/PlatformPostgreSQLImpl.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/platforms/PlatformPostgreSQLImpl.java?view=diff&rev=513569&r1=513568&r2=513569
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/platforms/PlatformPostgreSQLImpl.java (original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/platforms/PlatformPostgreSQLImpl.java Thu Mar 1 16:58:55 2007
@@ -21,6 +21,7 @@
import java.util.Properties;
import org.apache.ojb.broker.query.LikeCriteria;
+import org.apache.ojb.broker.query.Query;
import org.apache.ojb.broker.util.sequence.SequenceManagerHelper;
import org.apache.ojb.broker.metadata.JdbcConnectionDescriptor;
@@ -205,32 +206,29 @@
return "drop sequence " + sequenceName;
}
- /* (non-Javadoc)
- * @see org.apache.ojb.broker.platforms.Platform#addPagingSql(java.lang.StringBuffer)
- */
- public void addPagingSql(StringBuffer anSqlString)
- {
- anSqlString.append(" LIMIT ? OFFSET ?");
+ public boolean supportsLimit()
+ {
+ return true;
+ }
+
+ public StringBuffer addLimitSql(Query query, StringBuffer anSqlString)
+ {
+ return anSqlString.append(" LIMIT ?");
}
- /* (non-Javadoc)
- * @see org.apache.ojb.broker.platforms.Platform#supportsPaging()
- */
- public boolean supportsPaging()
+ public boolean supportsOffset()
{
return true;
}
- /* (non-Javadoc)
- * @see org.apache.ojb.broker.platforms.Platform#bindPagingParameters(java.sql.PreparedStatement, int, int, int)
- */
- public int bindPagingParameters(PreparedStatement ps, int index, int startAt, int endAt) throws SQLException
- {
- ps.setInt(index, endAt - (startAt - 1)); // number of rows to fetch
- index++;
- ps.setInt(index, startAt - 1); // zero based start
- index++;
- return index;
+ public StringBuffer addPagingSql(Query query, StringBuffer anSqlString)
+ {
+ return anSqlString.append(" LIMIT ? OFFSET ?");
+ }
+
+ public boolean limitBeforeOffset()
+ {
+ return true;
}
/**
Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/platforms/PlatformSapdbImpl.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/platforms/PlatformSapdbImpl.java?view=diff&rev=513569&r1=513568&r2=513569
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/platforms/PlatformSapdbImpl.java (original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/platforms/PlatformSapdbImpl.java Thu Mar 1 16:58:55 2007
@@ -24,6 +24,7 @@
import org.apache.ojb.broker.util.sequence.SequenceManagerHelper;
import org.apache.ojb.broker.metadata.FieldDescriptor;
import org.apache.ojb.broker.metadata.JdbcConnectionDescriptor;
+import org.apache.ojb.broker.query.Query;
import org.apache.commons.lang.SerializationUtils;
/**
@@ -277,31 +278,34 @@
return "select " + tableName + ".currval from DUAL";
}
- /* (non-Javadoc)
- * @see org.apache.ojb.broker.platforms.Platform#addPagingSql(java.lang.StringBuffer)
- */
- public void addPagingSql(StringBuffer anSqlString)
+ public boolean supportsLimit()
{
- anSqlString.append(" ROWNO <= ? ");
+ return true;
}
- /* (non-Javadoc)
- * @see org.apache.ojb.broker.platforms.Platform#bindPagingParameters(java.sql.PreparedStatement, int, int, int)
- */
- public int bindPagingParameters(PreparedStatement ps, int index, int startAt, int endAt) throws SQLException
+ public StringBuffer addLimitSql(Query query, StringBuffer anSqlString)
{
-
- ps.setInt(index, endAt - 1); // IGNORE startAt !!
- index++;
- return index;
+ return anSqlString.append(" LIMIT ?");
}
- /* (non-Javadoc)
- * @see org.apache.ojb.broker.platforms.Platform#supportsPaging()
- */
- public boolean supportsPaging()
+ public boolean supportsOffset()
{
return true;
+ }
+
+ public StringBuffer addPagingSql(Query query, StringBuffer anSqlString)
+ {
+ return anSqlString.append(" LIMIT ? ?");
+ }
+
+ public boolean limitBeforeOffset()
+ {
+ return false;
+ }
+
+ public boolean limitAfterSelect()
+ {
+ return false;
}
public boolean supportsOrderByInSubSelect()
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=513569&r1=513568&r2=513569
==============================================================================
--- 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 Mar 1 16:58:55 2007
@@ -19,17 +19,18 @@
import java.util.List;
import org.apache.ojb.broker.PersistenceBrokerInternal;
+import org.apache.ojb.broker.metadata.JdbcConnectionDescriptor;
+import org.apache.ojb.broker.platforms.Platform;
/**
* Abstract implemenation of Query interface
*
- * @author ???
* @version $Id$
*/
public abstract class AbstractQueryImpl implements Query, Serializable
{
- static final long serialVersionUID = -6265085604410295816L;
-
+ static final long serialVersionUID = -6265085604410295816L;
+
private int m_startAtIndex = Query.NO_START_AT_INDEX;
private int m_endAtIndex = Query.NO_END_AT_INDEX;
private int m_fullSize = 0;
@@ -39,6 +40,9 @@
private boolean m_withExtents = true;
private boolean selectForUpdate;
private String postfix;
+
+ private transient Platform platform;
+ private transient JdbcConnectionDescriptor jcd;
public AbstractQueryImpl()
{
@@ -64,105 +68,76 @@
{
return m_endAtIndex;
}
-
+
public void setEndAtIndex(int endAtIndex)
{
m_endAtIndex = endAtIndex;
}
-
+
public void fullSize(int size)
{
m_fullSize = size;
}
-
+
public int fullSize()
{
return m_fullSize;
}
-
+
public void setWithExtents(boolean withExtents)
{
m_withExtents = withExtents;
}
-
+
public boolean getWithExtents()
{
return m_withExtents;
}
- /*
- * @see Query#getSearchClass()
- */
public Class getSearchClass()
{
return m_searchClass;
}
- /*
- * @see Query#getBaseClass()
- */
public Class getBaseClass()
{
return m_baseClass;
}
- /* (non-Javadoc)
- * @see org.apache.ojb.broker.query.Query#getGroupBy()
- */
public List getGroupBy()
{
return null;
}
- /* (non-Javadoc)
- * @see org.apache.ojb.broker.query.Query#getOrderBy()
- */
public List getOrderBy()
{
return null;
}
- /* (non-Javadoc)
- * @see org.apache.ojb.broker.query.Query#getPrefetchedRelationships()
- */
public List getPrefetchedRelationships()
{
return null;
}
-
+ public Criteria getCriteria()
+ {
+ return null;
+ }
- /* (non-Javadoc)
- * @see org.apache.ojb.broker.query.Query#getCriteria()
- */
- public Criteria getCriteria()
- {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.apache.ojb.broker.query.Query#getExampleObject()
- */
- public Object getExampleObject()
- {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.apache.ojb.broker.query.Query#getHavingCriteria()
- */
- public Criteria getHavingCriteria()
- {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.apache.ojb.broker.query.Query#isDistinct()
- */
- public boolean isDistinct()
- {
- return false;
- }
+ public Object getExampleObject()
+ {
+ return null;
+ }
+
+ public Criteria getHavingCriteria()
+ {
+ return null;
+ }
+
+ public boolean isDistinct()
+ {
+ return false;
+ }
public boolean usePaging()
{
@@ -170,6 +145,16 @@
|| getStartAtIndex() > NO_START_AT_INDEX;
}
+ public boolean hasLimit()
+ {
+ return getEndAtIndex() > NO_END_AT_INDEX;
+ }
+
+ public boolean hasOffset()
+ {
+ return getStartAtIndex() > NO_START_AT_INDEX;
+ }
+
public void setFetchSize(int fetchSize)
{
this.fetchSize = fetchSize;
@@ -200,11 +185,76 @@
this.postfix = postfix;
}
+ public Platform getPlatform()
+ {
+ return platform;
+ }
+
+
+ // TODO: Rework the limit/offset support
+ private int[] limitValues = new int[]{};
+ /**
+ * NOTE: This method call is only valid after the query is build, more exactly after method
+ * {@link #prepareLimitAndOffset(StringBuffer)} was performed once.
+ */
+ public int[] getLimitValues()
+ {
+ return limitValues;
+ }
+
+ public StringBuffer prepareLimitAndOffset(StringBuffer stmt)
+ {
+ if(!usePaging() || !jcd.isNativeLimitOffset())
+ {
+ return stmt;
+ }
+
+ StringBuffer result = stmt;
+ Platform pf = getPlatform();
+ //int[] limitValues;
+ // limit with offset
+ if(hasOffset())
+ {
+ if(pf.supportsOffset())
+ {
+ result = pf.addPagingSql(this, result);
+ // check for embedded limit boundaries
+ if(!pf.limitOffsetValuesEmbedded())
+ {
+ if(pf.limitBeforeOffset())
+ {
+ limitValues = new int[]{pf.buildLimit(this), pf.buildOffset(this)};
+ }
+ else
+ {
+ limitValues = new int[]{pf.buildOffset(this), pf.buildLimit(this)};
+ }
+ }
+ }// fallback and add only limit if possible
+ else if(pf.supportsLimit())
+ {
+ result = pf.addLimitSql(this, result);
+ // check for embedded limit boundaries
+ if(!pf.limitOffsetValuesEmbedded()) limitValues = new int[]{pf.buildLimit(this)};
+ }
+ }
+ // only limit
+ else if(hasLimit() && pf.supportsLimit())
+ {
+ result = pf.addLimitSql(this, result);
+ // check for embedded limit boundaries
+ if(!pf.limitOffsetValuesEmbedded()) limitValues = new int[]{pf.buildLimit(this)};
+ }
+ return result;
+ }
+
/**
* @see org.apache.ojb.broker.query.Query#preprocess(org.apache.ojb.broker.PersistenceBrokerInternal)
*/
- public void preprocess(PersistenceBrokerInternal aPb)
+ public void preprocess(PersistenceBrokerInternal broker)
{
+ platform = broker.serviceConnectionManager().getSupportedPlatform();
+ jcd = broker.serviceConnectionManager().getConnectionDescriptor();
}
}
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=513569&r1=513568&r2=513569
==============================================================================
--- 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 Mar 1 16:58:55 2007
@@ -16,6 +16,7 @@
*/
import java.util.List;
+import java.io.Serializable;
import org.apache.ojb.broker.PersistenceBrokerInternal;
@@ -41,10 +42,9 @@
* projects without breaking any references. I hope this will be
* useful for someone.
*
- * @author Thomas Mahler
* @version $Id$
*/
-public interface Query extends java.io.Serializable
+public interface Query extends Serializable
{
static final long serialVersionUID = 7616997212439931319L;
@@ -126,6 +126,21 @@
void setEndAtIndex(int endAtIndex);
/**
+ * Answer true if endIndex and/or startIndex is set.
+ */
+ public boolean usePaging();
+
+ /**
+ * Returns <em>true</em> if the {@link #setEndAtIndex(int)} is set.
+ */
+ public boolean hasLimit();
+
+ /**
+ * Returns <em>true</em> if the {@link #setStartAtIndex(int)} is set.
+ */
+ public boolean hasOffset();
+
+ /**
* Returns the names of Relationships to be prefetched
* @return List of Strings
*/
@@ -137,17 +152,19 @@
*/
void fullSize(int size);
/**
- * @deprecated use OJBIterator.fullSize()
+ * @deprecated use {@link org.apache.ojb.broker.accesslayer.OJBIterator#fullSize()}.
*/
int fullSize();
+ /**
+ * Internal used method.
+ */
void setWithExtents(boolean withExtents);
- boolean getWithExtents();
-
+
/**
- * Answer true if start- and endIndex is set.
+ * Internal used method.
*/
- public boolean usePaging();
+ boolean getWithExtents();
/**
* Set fetchSize hint for this Query. Passed to the JDBC driver on the
@@ -194,10 +211,13 @@
String getQueryAffix();
/**
+ * INTERNAL CALLED METHOD!
* Preprocess the Query using a PersistenceBroker.
+ * NOTE: This method can be called
+ * more than once before the query is performed.
*
- * @param aPb the PersistenceBroker
+ * @param broker The current used broker instance.
*/
- public void preprocess(PersistenceBrokerInternal aPb);
+ public void preprocess(PersistenceBrokerInternal broker);
}
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=513569&r1=513568&r2=513569
==============================================================================
--- 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 Thu Mar 1 16:58:55 2007
@@ -540,6 +540,7 @@
*/
public void preprocess(PersistenceBrokerInternal aPb)
{
+ super.preprocess(aPb);
if (getCriteria() != null)
{
getCriteria().preprocess(aPb);
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org