Class EntityFindOptions
- All Implemented Interfaces:
Serializable
EntityFindOptions options1 = new EntityFindOptions().distinct().limit(10);
EntityFindOptions options2 = EntityFindOptions.findOptions()
.scrollInsensitive()
.updatable()
.fetchSize(30);
- Since:
- Aug 8, 2002
- Version:
- 1.0
- Author:
- David E. Jones
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDeprecated.use the original constant insteadstatic final intDeprecated.use the original constant insteadprotected booleanprotected intprotected intmaximum results to obtain from DB - negative values mean no limitprotected intprotected intprotected intprotected booleanstatic final intDeprecated.use the original constant insteadstatic final intDeprecated.use the original constant insteadstatic final intDeprecated.use the original constant instead -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.EntityFindOptions(boolean specifyTypeAndConcurrency, int resultSetType, int resultSetConcurrency, boolean distinct, int maxResults) Deprecated.since 1.0.27 - Please use the chained form as shown in theexamples. -
Method Summary
Modifier and TypeMethodDescriptiondistinct()Same assetDistinct(true).fetchSize(int fetchSize) Same assetFetchSize(int).static EntityFindOptionsCreates a newEntityFindOptions.Same as using bothsetSpecifyTypeAndConcur(true)andsetResultSetType(TYPE_FORWARD_ONLY).booleanIndicates whether the values returned will be filtered to remove duplicate values.intSpecifies the value to use for the fetch size on the prepared statement.intSpecifies the maximum number of results to be returned by the query.intReturns the number of rows to be skipped.intSpecifies whether or not the ResultSet can be updated.intIndicates how the ResultSet will be traversed.booleanDeprecated.useisCustomResultSetTypeAndConcurrency()instead; better namedbooleanIndicates whether theresultSetTypeandresultSetConcurrencyfields will be used to specify how the results will be used; false means that the JDBC driver's default values will be used.maxResults(int maxResults) Same assetMaxResults(int).range(int offset, int maxResults) Specifies the range of results to find.readOnly()Same as using bothsetSpecifyTypeAndConcur(true)andsetResultSetConcurrency(int)setResultSetConcurrency(CONCUR_READ_ONLY)}.Same as using bothsetSpecifyTypeAndConcur(true)andsetResultSetType(TYPE_SCROLL_INSENSITIVE).Same as using bothsetSpecifyTypeAndConcur(true)andsetResultSetType(TYPE_SCROLL_SENSITIVE).voidsetDistinct(boolean distinct) Specifies whether the values returned should be filtered to remove duplicate values.voidsetFetchSize(int fetchSize) Specifies the value to use for the fetch size on the prepared statement.voidsetMaxResults(int maxResults) Specifies the maximum number of results to be returned by the query.voidsetOffset(int offset) Specifies the number of rows to be skipped, which is ignored ifmaxResultsis not also set.voidsetResultSetConcurrency(int resultSetConcurrency) Specifies whether or not the ResultSet can be updated.voidsetResultSetType(int resultSetType) Specifies how the ResultSet will be traversed.voidsetSpecifyTypeAndConcur(boolean specifyTypeAndConcurrency) Deprecated.there's no valid use case for this method; calluseDriverDefaultsForTypeAndConcurrency()to revert to the driver's default settings for concurrency and type of result setSame as using bothsetSpecifyTypeAndConcur(true)andsetResultSetConcurrency(int)setResultSetConcurrency(CONCUR_UPDATABLE)}.voidSpecifies that the JDBC driver's default values should be used for concurrency and type of result set, in other words any custom settings for those options should be ignored.
-
Field Details
-
TYPE_FORWARD_ONLY
Deprecated.use the original constant insteadType constant from the java.sql.ResultSet object for convenience.- See Also:
-
TYPE_SCROLL_INSENSITIVE
Deprecated.use the original constant insteadType constant from the java.sql.ResultSet object for convenience.- See Also:
-
TYPE_SCROLL_SENSITIVE
Deprecated.use the original constant insteadType constant from the java.sql.ResultSet object for convenience.- See Also:
-
CONCUR_READ_ONLY
Deprecated.use the original constant insteadType constant from the java.sql.ResultSet object for convenience.- See Also:
-
CONCUR_UPDATABLE
Deprecated.use the original constant insteadType constant from the java.sql.ResultSet object for convenience.- See Also:
-
specifyTypeAndConcurrency
protected boolean specifyTypeAndConcurrency -
resultSetType
protected int resultSetType -
resultSetConcurrency
protected int resultSetConcurrency -
distinct
protected boolean distinct -
maxResults
protected int maxResultsmaximum results to obtain from DB - negative values mean no limit -
offset
protected int offset -
fetchSize
protected int fetchSize
-
-
Constructor Details
-
EntityFindOptions
public EntityFindOptions()Default constructor. Defaults are as follows: specifyTypeAndConcurrency = true resultSetType = TYPE_FORWARD_ONLY resultSetConcurrency = CONCUR_READ_ONLY distinct = false maxResults = -1 (no limit) fetchSize = -1 (use driver's default setting) -
EntityFindOptions
@Deprecated public EntityFindOptions(boolean specifyTypeAndConcurrency, int resultSetType, int resultSetConcurrency, boolean distinct, int maxResults) Deprecated.since 1.0.27 - Please use the chained form as shown in theexamples.Constructor that allows some options to be provided at construction time.- Parameters:
specifyTypeAndConcurrency- iffalse, then resultSetType and resultSetConcurrency are ignored, and the JDBC driver's defaults are used for these fields, insteadresultSetType- eitherTYPE_FORWARD_ONLY,TYPE_SCROLL_INSENSITIVE, orTYPE_SCROLL_SENSITIVEresultSetConcurrency- eitherCONCUR_READ_ONLY, orCONCUR_UPDATABLEdistinct- iftrue, then theDISTINCTSQL keyword is used in the querymaxResults- if specified, then this value is used to limit the number of results retrieved, by usingLIMITon MySQL,ROWNUMon Oracle, and so on
-
-
Method Details
-
findOptions
Creates a newEntityFindOptions. This is equivalent to thedefault constructor, but is implemented as a static method so that it can be used more conveniently by other classes thatstatic importit.Example:
import org.ofbiz.core.entity.EntityFindOptions; import static org.ofbiz.core.entity.EntityFindOptions.findOptions; [...] { EntityFindOptions options = findOptions().distinct().maxEntries(5); [...] }- Returns:
- the new options
-
getSpecifyTypeAndConcur
Deprecated.useisCustomResultSetTypeAndConcurrency()instead; better namedIndicates whether theresultSetTypeandresultSetConcurrencyfields will be used to specify how the results will be used; false means that the JDBC driver's default values will be used.- Returns:
- see above
-
isCustomResultSetTypeAndConcurrency
public boolean isCustomResultSetTypeAndConcurrency()Indicates whether theresultSetTypeandresultSetConcurrencyfields will be used to specify how the results will be used; false means that the JDBC driver's default values will be used.- Returns:
- see above
-
setSpecifyTypeAndConcur
Deprecated.there's no valid use case for this method; calluseDriverDefaultsForTypeAndConcurrency()to revert to the driver's default settings for concurrency and type of result setSetting this to true means that theresultSetTypeandresultSetConcurrencyparameters will be used to specify how the results will be used; if false, the JDBC driver's default values will be used.- Parameters:
specifyTypeAndConcurrency- see above
-
useDriverDefaultsForTypeAndConcurrency
public void useDriverDefaultsForTypeAndConcurrency()Specifies that the JDBC driver's default values should be used for concurrency and type of result set, in other words any custom settings for those options should be ignored. -
getResultSetType
public int getResultSetType()Indicates how the ResultSet will be traversed.- Returns:
- the result set type
- See Also:
-
setResultSetType
public void setResultSetType(int resultSetType) Specifies how the ResultSet will be traversed. Available values:ResultSet.TYPE_FORWARD_ONLY,ResultSet.TYPE_SCROLL_INSENSITIVE, andResultSet.TYPE_SCROLL_SENSITIVE. If you want it to be fast, use the common default,ResultSet.TYPE_FORWARD_ONLY.- Parameters:
resultSetType- the result set type to set
-
getResultSetConcurrency
public int getResultSetConcurrency()Specifies whether or not the ResultSet can be updated. Available values: ResultSet.CONCUR_READ_ONLY or ResultSet.CONCUR_UPDATABLE. Should pretty much always be ResultSet.CONCUR_READ_ONLY with the Entity Engine.- Returns:
- see above
-
setResultSetConcurrency
public void setResultSetConcurrency(int resultSetConcurrency) Specifies whether or not the ResultSet can be updated. Available values: ResultSet.CONCUR_READ_ONLY or ResultSet.CONCUR_UPDATABLE. Should pretty much always be ResultSet.CONCUR_READ_ONLY with the Entity Engine.- Parameters:
resultSetConcurrency- the value to set
-
getDistinct
public boolean getDistinct()Indicates whether the values returned will be filtered to remove duplicate values.- Returns:
- see above
-
setDistinct
public void setDistinct(boolean distinct) Specifies whether the values returned should be filtered to remove duplicate values.- Parameters:
distinct- whether to return only unique values
-
getMaxResults
public int getMaxResults()Specifies the maximum number of results to be returned by the query.- Returns:
- see above
-
setMaxResults
public void setMaxResults(int maxResults) Specifies the maximum number of results to be returned by the query. Must be positive.- Parameters:
maxResults- ignored if zero or less
-
getOffset
public int getOffset()Returns the number of rows to be skipped.- Returns:
- see above
-
setOffset
public void setOffset(int offset) Specifies the number of rows to be skipped, which is ignored ifmaxResultsis not also set.- Parameters:
offset- if negative, this method does nothing
-
getFetchSize
public int getFetchSize()Specifies the value to use for the fetch size on the prepared statement. Please see the comments insetFetchSize(int)for restrictions.- Returns:
- the fetch size
-
setFetchSize
public void setFetchSize(int fetchSize) Specifies the value to use for the fetch size on the prepared statement. Note that the values that may be used are database-dependent. Use this with caution!WARNING: This setting is a hint for the database driver, and the driver is not required to honour it! Several databases put other restrictions on its use as well. Postgres will definitely ignore this setting when the database connection is in auto-commit mode, so you will probably have to use the
TransactionUtilif you want this to work.WARNING: This value may need to be set to a database-dependent value. For example, the most useful value on MySQL is
Integer.MIN_VALUEto get a streaming result set, but this value will be rejected by most other databases. -
forwardOnly
Same as using bothsetSpecifyTypeAndConcur(true)andsetResultSetType(TYPE_FORWARD_ONLY). Note that you should also use eitherreadOnly()orupdatable()for maximum driver compatibility.- Returns:
this, for convenient use as a chained builder
-
scrollSensitive
Same as using bothsetSpecifyTypeAndConcur(true)andsetResultSetType(TYPE_SCROLL_SENSITIVE). Note that you should also use eitherreadOnly()orupdatable()for maximum driver compatibility.- Returns:
this, for convenient use as a chained builder
-
scrollInsensitive
Same as using bothsetSpecifyTypeAndConcur(true)andsetResultSetType(TYPE_SCROLL_INSENSITIVE). Note that you should also use eitherreadOnly()orupdatable()for maximum driver compatibility.- Returns:
this, for convenient use as a chained builder
-
readOnly
Same as using bothsetSpecifyTypeAndConcur(true)andsetResultSetConcurrency(int)setResultSetConcurrency(CONCUR_READ_ONLY)}. Note that you should also useforwardOnly(),scrollSensitive()orscrollInsensitive()for maximum driver compatibility.- Returns:
this, for convenient use as a chained builder
-
updatable
Same as using bothsetSpecifyTypeAndConcur(true)andsetResultSetConcurrency(int)setResultSetConcurrency(CONCUR_UPDATABLE)}. Note that you should also useforwardOnly(),scrollSensitive()orscrollInsensitive()for maximum driver compatibility.- Returns:
this, for convenient use as a chained builder
-
distinct
Same assetDistinct(true).- Returns:
this, for convenient use as a chained builder
-
maxResults
Same assetMaxResults(int).- Returns:
this, for convenient use as a chained builder
-
fetchSize
Same assetFetchSize(int).- Returns:
this, for convenient use as a chained builder
-
range
Specifies the range of results to find.- Parameters:
offset- the offset from which to startmaxResults- the maximum number of results to find- Returns:
this, for convenient use as a chained builder
-