Class SearchSQL
- java.lang.Object
-
- com.filenet.api.query.SearchSQL
-
public class SearchSQL extends java.lang.Object
A helper class used to assist in building valid SQL statements. An instance of this class is passed in to theSearchScope.fetchObjects
andSearchScope.fetchRows
methods to perform a query.The
SearchSQL
class can be used in either of the following ways:-
Use the helper methods to specify the parts of the SQL statement. For example, use
setFromClauseInitialValue
to set the name of the class being searched,setSelectList
to set the names of the properties to include, andsetWhereClause
to specify what to search for. When theSearchSQL
instance is passed in as an argument toSearchScope.fetchRows
, the complete SQL statement string is constructed out of the parts supplied by the calls to the SearchSQL helper methods. You also can get the complete SQL statement string constructed by calling thetoString
method. -
Pass in a complete SQL statement. If you have the complete SQL statement that needs to be executed, pass the
SQL statement in to either the
setQueryString
method or theSearchSQL(String)
constructor. TheSearchSQL
instance is then complete, and no otherSearchSQL
method can be called on this instance.
The settings for the following properties can directly affect the search behavior:
ObjectStore.DefaultQueryTimeLimit
ObjectStore.MaxQueryTimeLimit
ObjectStore.QueryDatabaseTimeout
ServerCacheConfiguration.QueryPageMaxSize
ServerCacheConfiguration.QueryPageDefaultSize
ServerCacheConfiguration.NonPagedQueryMaxSize
ServerCacheConfiguration.QueryCountDefaultSize
ServerCacheConfiguration.QueryCountMaxSize
Note: Date/Time values in queries are evaluated with respect to the Content Engine server clock. If the client and server clocks are not in sync, be careful when translating relative time concepts into absolute times. For example, specifying a value that means "within the last 5 minutes" on the client will translate to a comparison to an absolute time in the SQL query, which may not mean "within the last 5 minutes" relative to the server clock.
- See Also:
- SQL Syntax Reference
-
Use the helper methods to specify the parts of the SQL statement. For example, use
-
-
Constructor Summary
Constructors Constructor and Description SearchSQL()
Use this when you are going to build the SQL statement using theSearchSQL
helper methods, rather than passing in the complete SQL statement.SearchSQL(java.lang.String queryString)
Specify the complete SQL statement as a string.
-
Method Summary
Methods Modifier and Type Method and Description void
setAll()
Specifies that duplicate rows can be returned in the result set.void
setContainsRestriction(java.lang.String symbolicClassName, java.lang.String searchExpression)
Restricts the query to return only items where the text in the content element or elements matches the specified string.void
setContainsRestriction(java.lang.String symbolicClassName, java.lang.String searchExpression, java.lang.String searchDialect)
Restricts the query to return only items where the text in the content element or elements matches the specified string.void
setDistinct()
Restricts the query to return only distinct rows.void
setFolderRestriction(java.lang.String symbolicClassName, java.lang.String folderName)
Restricts the query to return only items from the specified class within the specified folder.void
setFreetextRestriction(java.lang.String symbolicClassName, java.lang.String searchExpression)
Deprecated.As of release 5.2.0void
setFromClauseAdditionalJoin(JoinOperator joinOperator, java.lang.String symbolicClassName, java.lang.String aliasName, java.lang.String joinVar1, JoinComparison joinComparison, java.lang.String joinVar2, boolean includeSubclasses)
Adds another class to the FROM clause used in the SQL statement.void
setFromClauseInitialValue(java.lang.String symbolicClassName, java.lang.String aliasName, boolean includeSubclasses)
Sets the first class to be used in the FROM clause for the statement.void
setMaxRecords(int maxRecords)
Sets the maximum number of rows that can be returned in the result set.void
setOrderByClause(java.lang.String orderByClause)
Sets the ORDER BY clause to be used for the SQL statement to the specified string.void
setQueryString(java.lang.String queryString)
Specifies the complete SQL statement.void
setSelectList(java.lang.String selectList)
Sets the SELECT list for SQL statement to the string specified.void
setTimeLimit(int timeLimit)
Sets the maximum duration the query runs on the server, in seconds.void
setWhereClause(java.lang.String whereClause)
Sets the WHERE clause to be used for the SQL statement to the specified string.java.lang.String
toString()
Returns either the SQL statement constructed using the helper methods (in this case,setFromClauseInitialValue
must have been called prior to this method), or the SQL statement specified in its entirety using eithersetQueryString
or theSearchSQL(String)
constructor.
-
-
-
Constructor Detail
-
SearchSQL
public SearchSQL()
Use this when you are going to build the SQL statement using theSearchSQL
helper methods, rather than passing in the complete SQL statement.
-
SearchSQL
public SearchSQL(java.lang.String queryString)
Specify the complete SQL statement as a string. Do not use this in conjunction with anySearchSQL
methods. Calling any of methods on this instance will either overwrite or nullify the SQL statement specified here.No SQL validation is performed on the specified string.
- Parameters:
queryString
- AString
containing he complete SQL statement to use.- See Also:
setQueryString(String)
, SQL Syntax Reference
-
-
Method Detail
-
setSelectList
public void setSelectList(java.lang.String selectList)
Sets the SELECT list for SQL statement to the string specified. This must be called prior to callingsetFromClauseAdditionalJoin
.- Parameters:
selectList
- AString
containing the query SELECT list.- Throws:
EngineRuntimeException
- Thrown when the parameter isnull
or invalid.
-
setFromClauseInitialValue
public void setFromClauseInitialValue(java.lang.String symbolicClassName, java.lang.String aliasName, boolean includeSubclasses)
Sets the first class to be used in the FROM clause for the statement.- Parameters:
symbolicClassName
- AString
containing the symbolic name of the class.aliasName
- AString
containing the alias name of the class. This can benull
.Note: Alias names cannot be used when
EngineObject
objects are to be returned by the query operation.includeSubclasses
- Aboolean
value of true if the FROM clause should include any subclasses of the class specified insymbolicClassName
; false otherwise.- Throws:
EngineRuntimeException
- Thrown when a required parameter isnull
or invalid.
-
setFromClauseAdditionalJoin
public void setFromClauseAdditionalJoin(JoinOperator joinOperator, java.lang.String symbolicClassName, java.lang.String aliasName, java.lang.String joinVar1, JoinComparison joinComparison, java.lang.String joinVar2, boolean includeSubclasses)
Adds another class to the FROM clause used in the SQL statement.- Parameters:
joinOperator
- AJoinOperator
instance specifying the type of join to use for the additional class.symbolicClassName
- AString
containing the symbolic name of the class.aliasName
- AString
containing the alias name of the class. This can benull
. Note: Alias names cannot be used whenEngineObject
objects are to be returned by the query operation.joinVar1
- AString
containing the name of a property on the initial class specified insetFromClauseInitialValue
. In tandem with the property specified injoinVar2
, this property specifies the ON clause constituents of the join.joinComparison
- AJoinComparison
instance specifying the comparison to use for the constituents of the ON clause (joinVar1
andjoinVar2
).joinVar2
- AString
containing the name of a property on the class specified insymbolicClassName
. In tandem with the property specified injoinVar1
, this property specifies the ON clause constituents of the join.includeSubclasses
- Aboolean
value of true if the FROM clause should include any subclasses of the class specified insymbolicClassName
; false otherwise.- Throws:
EngineRuntimeException
- Thrown when a required parameter isnull
or invalid.
-
setWhereClause
public void setWhereClause(java.lang.String whereClause)
Sets the WHERE clause to be used for the SQL statement to the specified string.- Parameters:
whereClause
- AString
containing the WHERE clause to use.- Throws:
EngineRuntimeException
- Thrown when the parameter isnull
or invalid.
-
setOrderByClause
public void setOrderByClause(java.lang.String orderByClause)
Sets the ORDER BY clause to be used for the SQL statement to the specified string.- Parameters:
orderByClause
- AString
containing the property or properties to use for the ORDER BY clause. You can specify multiple property names separated by commas.- Throws:
EngineRuntimeException
- Thrown when the parameter isnull
or invalid.
-
setFolderRestriction
public void setFolderRestriction(java.lang.String symbolicClassName, java.lang.String folderName)
Restricts the query to return only items from the specified class within the specified folder.- Parameters:
symbolicClassName
- AString
containing the symbolic name of the class.folderName
- AString
containing the name of the folder storing the class.- Throws:
EngineRuntimeException
- Thrown when the parameters arenull
or invalid.
-
setFreetextRestriction
public void setFreetextRestriction(java.lang.String symbolicClassName, java.lang.String searchExpression)
Deprecated. As of release 5.2.0Restricts the query to return only items where the text in the content elements matches the specified string. This method uses the FREETEXT function for CBR (Content-Based Retrieval) queries.The FREETEXT function searches all content on all CBR-enabled properties on the supported content elements. To search content on a single CBR-enabled property, use
setContainsRestriction
.- Parameters:
symbolicClassName
- AString
containing the symbolic name of the class.searchExpression
- AString
containing the search text to use for the FREETEXT function.- Throws:
EngineRuntimeException
- Thrown when the parameters arenull
or invalid.- See Also:
setContainsRestriction(java.lang.String, java.lang.String)
, The FREETEXT Function in the SQL Syntax Reference
-
setContainsRestriction
public void setContainsRestriction(java.lang.String symbolicClassName, java.lang.String searchExpression)
Restricts the query to return only items where the text in the content element or elements matches the specified string. This method uses the CONTAINS function for CBR (Content-Based Retrieval) queries.The CONTAINS function can perform the search on CBR-enabled properties for the supported content elements in any of the following ways:
- Search a single property
- Search all properties within a specified zone
- Search all properties
- Parameters:
symbolicClassName
- AString
containing the symbolic name of the class.searchExpression
- AString
containing the search text to use for the CONTAINS function.- Throws:
EngineRuntimeException
- Thrown when the parameters arenull
or invalid.- See Also:
setFreetextRestriction(java.lang.String, java.lang.String)
, The CONTAINS Function in the SQL Syntax Reference
-
setContainsRestriction
public void setContainsRestriction(java.lang.String symbolicClassName, java.lang.String searchExpression, java.lang.String searchDialect)
Restricts the query to return only items where the text in the content element or elements matches the specified string. This method uses the CONTAINS function for CBR (Content-Based Retrieval) queries.The CONTAINS function can perform the search on CBR-enabled properties for the supported content elements in any of the following ways:
- Search a single property
- Search all properties within a specified zone
- Search all properties
- Parameters:
symbolicClassName
- AString
containing the symbolic name of the class.searchExpression
- AString
containing the search text to use for the CONTAINS function.searchDialect
- AString
containing the search dialect to use which can be Lucene, K2VQL or null.- Throws:
E_NULL_OR_INVALID_PARAM_VALUE
- IfsymbolicClassName
orsearchExpression
isnull
or has a length of zero.CBR_INVALID_SEARCH_DIALECT
- IfsearchDialect
is not null and neither Lucene nor K2VQL.- See Also:
setFreetextRestriction(java.lang.String, java.lang.String)
, The CONTAINS Function in the SQL Syntax Reference
-
setDistinct
public void setDistinct()
Restricts the query to return only distinct rows. This setting is valid only when all properties in the select list are orderable (as specified in the ORDER BY clause).- See Also:
setOrderByClause(java.lang.String)
-
setAll
public void setAll()
Specifies that duplicate rows can be returned in the result set.
-
setMaxRecords
public void setMaxRecords(int maxRecords)
Sets the maximum number of rows that can be returned in the result set. When unspecified, all records that satisfy the query will be returned, subject to the limit ofServerCacheConfiguration
propertyNonPagedQueryMaxSize
.- Parameters:
maxRecords
- An integer specifying the maximum number of rows to be returned. If unspecified, the limit is determined byServerCacheConfiguration.NonPagedQueryMaxSize
.- Throws:
EngineRuntimeException
- Thrown when the parameter is invalid.- See Also:
ServerCacheConfiguration.get_QueryPageDefaultSize
,ServerCacheConfiguration.get_QueryPageMaxSize
,ServerCacheConfiguration.get_NonPagedQueryMaxSize
-
setTimeLimit
public void setTimeLimit(int timeLimit)
Sets the maximum duration the query runs on the server, in seconds. When unspecified, the value of theObjectStore
propertyDefaultQueryTimeLimit
is used.Warning: Date/Time values in queries are evaluated with respect to the Content Engine server clock. If the client and server clocks are not in sync, be careful when translating relative time concepts into absolute times. For example, specifying a value that means "within the last 5 minutes" on the client will translate to a comparison to an absolute time in the SQL query, which may not mean "within the last 5 minutes" relative to the server clock.
- Parameters:
timeLimit
- An integer specifying the maximum duration of the query. If unspecified,ObjectStore.DefaultQueryTimeLimit
is used.- Throws:
EngineRuntimeException
- Thrown when the parameter is invalid.- See Also:
ObjectStore.get_DefaultQueryTimeLimit
-
setQueryString
public void setQueryString(java.lang.String queryString)
Specifies the complete SQL statement. This method cannot be used in conjunction with any other set method on this class. Doing so will have the following effect:- Any values set by calling another
SearchSQL
set method (such as,setMaxRecords
), then calling this method will overwrite or nullify the value initially set. - Calling this method, then calling any other
SearchSQL
set method will overwrite or nullify the SQL statement specified here.
No SQL validation is performed on the specified string.
- Parameters:
queryString
- AString
containing the SQL statement to use.- See Also:
- SQL Syntax Reference
- Any values set by calling another
-
toString
public java.lang.String toString()
Returns either the SQL statement constructed using the helper methods (in this case,setFromClauseInitialValue
must have been called prior to this method), or the SQL statement specified in its entirety using eithersetQueryString
or theSearchSQL(String)
constructor.- Overrides:
toString
in classjava.lang.Object
- Returns:
- A
String
containing the SQL statement used for this instance. - Throws:
EngineRuntimeException
- Thrown when the SQL statement is null. Either the SQL statement was not set (constructed or specified in its entirety), or was nullified by calling one of theSearchSQL
methods subsequent to using eithersetQueryString
or theSearchSQL(String)
constructor.- See Also:
setFromClauseInitialValue(java.lang.String, java.lang.String, boolean)
,setQueryString(java.lang.String)
-
-