Class SearchSQL
- java.lang.Object
-
- com.filenet.api.query.SearchSQL
-
public class SearchSQL extends java.lang.ObjectA helper class used to assist in building valid SQL statements. An instance of this class is passed in to theSearchScope.fetchObjectsandSearchScope.fetchRowsmethods to perform a query.The
SearchSQLclass can be used in either of the following ways:-
Use the helper methods to specify the parts of the SQL statement. For example, use
setFromClauseInitialValueto set the name of the class being searched,setSelectListto set the names of the properties to include, andsetWhereClauseto specify what to search for. When theSearchSQLinstance 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 thetoStringmethod. -
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
setQueryStringmethod or theSearchSQL(String)constructor. TheSearchSQLinstance is then complete, and no otherSearchSQLmethod can be called on this instance.
The settings for the following properties can directly affect the search behavior:
ObjectStore.DefaultQueryTimeLimitObjectStore.MaxQueryTimeLimitObjectStore.QueryDatabaseTimeoutServerCacheConfiguration.QueryPageMaxSizeServerCacheConfiguration.QueryPageDefaultSizeServerCacheConfiguration.NonPagedQueryMaxSizeServerCacheConfiguration.QueryCountDefaultSizeServerCacheConfiguration.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 theSearchSQLhelper methods, rather than passing in the complete SQL statement.SearchSQL(java.lang.String queryString)Specify the complete SQL statement as a string.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method and Description voidsetAll()Specifies that duplicate rows can be returned in the result set.voidsetContainsRestriction(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.voidsetContainsRestriction(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.voidsetDistinct()Restricts the query to return only distinct rows.voidsetFolderRestriction(java.lang.String symbolicClassName, java.lang.String folderName)Restricts the query to return only items from the specified class within the specified folder.voidsetFreetextRestriction(java.lang.String symbolicClassName, java.lang.String searchExpression)Deprecated.As of release 5.2.0voidsetFromClauseAdditionalJoin(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.voidsetFromClauseInitialValue(java.lang.String symbolicClassName, java.lang.String aliasName, boolean includeSubclasses)Sets the first class to be used in the FROM clause for the statement.voidsetMaxRecords(int maxRecords)Sets the maximum number of rows that can be returned in the result set.voidsetOrderByClause(java.lang.String orderByClause)Sets the ORDER BY clause to be used for the SQL statement to the specified string.voidsetQueryString(java.lang.String queryString)Specifies the complete SQL statement.voidsetSelectList(java.lang.String selectList)Sets the SELECT list for SQL statement to the string specified.voidsetTimeLimit(int timeLimit)Sets the maximum duration the query runs on the server, in seconds.voidsetWhereClause(java.lang.String whereClause)Sets the WHERE clause to be used for the SQL statement to the specified string.java.lang.StringtoString()Returns either the SQL statement constructed using the helper methods (in this case,setFromClauseInitialValuemust have been called prior to this method), or the SQL statement specified in its entirety using eithersetQueryStringor theSearchSQL(String)constructor.
-
-
-
Constructor Detail
-
SearchSQL
public SearchSQL()
Use this when you are going to build the SQL statement using theSearchSQLhelper 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 anySearchSQLmethods. 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- AStringcontaining 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- AStringcontaining the query SELECT list.- Throws:
EngineRuntimeException- Thrown when the parameter isnullor 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- AStringcontaining the symbolic name of the class.aliasName- AStringcontaining the alias name of the class. This can benull.Note: Alias names cannot be used when
EngineObjectobjects are to be returned by the query operation.includeSubclasses- Abooleanvalue of true if the FROM clause should include any subclasses of the class specified insymbolicClassName; false otherwise.- Throws:
EngineRuntimeException- Thrown when a required parameter isnullor 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- AJoinOperatorinstance specifying the type of join to use for the additional class.symbolicClassName- AStringcontaining the symbolic name of the class.aliasName- AStringcontaining the alias name of the class. This can benull. Note: Alias names cannot be used whenEngineObjectobjects are to be returned by the query operation.joinVar1- AStringcontaining 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- AJoinComparisoninstance specifying the comparison to use for the constituents of the ON clause (joinVar1andjoinVar2).joinVar2- AStringcontaining 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- Abooleanvalue of true if the FROM clause should include any subclasses of the class specified insymbolicClassName; false otherwise.- Throws:
EngineRuntimeException- Thrown when a required parameter isnullor 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- AStringcontaining the WHERE clause to use.- Throws:
EngineRuntimeException- Thrown when the parameter isnullor 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- AStringcontaining 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 isnullor 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- AStringcontaining the symbolic name of the class.folderName- AStringcontaining the name of the folder storing the class.- Throws:
EngineRuntimeException- Thrown when the parameters arenullor 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- AStringcontaining the symbolic name of the class.searchExpression- AStringcontaining the search text to use for the FREETEXT function.- Throws:
EngineRuntimeException- Thrown when the parameters arenullor 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- AStringcontaining the symbolic name of the class.searchExpression- AStringcontaining the search text to use for the CONTAINS function.- Throws:
EngineRuntimeException- Thrown when the parameters arenullor 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- AStringcontaining the symbolic name of the class.searchExpression- AStringcontaining the search text to use for the CONTAINS function.searchDialect- AStringcontaining the search dialect to use which can be Lucene, K2VQL or null.- Throws:
E_NULL_OR_INVALID_PARAM_VALUE- IfsymbolicClassNameorsearchExpressionisnullor has a length of zero.CBR_INVALID_SEARCH_DIALECT- IfsearchDialectis 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 ofServerCacheConfigurationpropertyNonPagedQueryMaxSize.- 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 theObjectStorepropertyDefaultQueryTimeLimitis 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.DefaultQueryTimeLimitis 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
SearchSQLset method (such as,setMaxRecords), then calling this method will overwrite or nullify the value initially set. - Calling this method, then calling any other
SearchSQLset method will overwrite or nullify the SQL statement specified here.
No SQL validation is performed on the specified string.
- Parameters:
queryString- AStringcontaining 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,setFromClauseInitialValuemust have been called prior to this method), or the SQL statement specified in its entirety using eithersetQueryStringor theSearchSQL(String)constructor.- Overrides:
toStringin classjava.lang.Object- Returns:
- A
Stringcontaining 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 theSearchSQLmethods subsequent to using eithersetQueryStringor theSearchSQL(String)constructor.- See Also:
setFromClauseInitialValue(java.lang.String, java.lang.String, boolean),setQueryString(java.lang.String)
-
-