Package org.olap4j.query
Class Query
java.lang.Object
org.olap4j.query.Query
Base query model object.
- Since:
- May 29, 2007
- Author:
- jhyde, jdixon, Luc Boudreau
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
execute()
Executes the query against the current OlapConnection and returns a CellSet object representation of the data.getAxes()
Returns a map of the current query's axis.Returns the query axis for a given axis type.getCube()
Returns the underlying cube object that is used to query against.getDimension
(String name) Returns the Olap4j's Dimension object according to the name given as a parameter.Returns the current locale with which this query is expressed.getName()
Returns this query's name.Returns the MDX parse tree behind this Query.Returns the fictional axis into which all unused dimensions are stored.void
void
setSelectDefaultMembers
(boolean selectDefaultMembers) Behavior setter for a query.void
swapAxes()
Swaps rows and columns axes.void
tearDown()
Safely disposes of all underlying objects of this query and closes the underlyingOlapConnection
.void
tearDown
(boolean closeConnection) Safely disposes of all underlying objects of this query.void
validate()
Validates the current query structure.
-
Constructor Details
-
Query
Constructs a Query object.- Parameters:
name
- Any arbitrary name to give to this query.cube
- A Cube object against which to build a query.- Throws:
SQLException
- If an error occurs while accessing the cube's underlying connection.
-
-
Method Details
-
getSelect
Returns the MDX parse tree behind this Query. The returned object is generated for each call to this function. Altering the returned SelectNode object won't affect the query itself.- Returns:
- A SelectNode object representing the current query structure.
-
getCube
Returns the underlying cube object that is used to query against.- Returns:
- The Olap4j's Cube object.
-
getDimension
Returns the Olap4j's Dimension object according to the name given as a parameter. If no dimension of the given name is found, a null value will be returned.- Parameters:
name
- The name of the dimension you want the object for.- Returns:
- The dimension object, null if no dimension of that name can be found.
-
swapAxes
public void swapAxes()Swaps rows and columns axes. Only applicable if there are two axes. -
getAxis
Returns the query axis for a given axis type.If you pass axis=null, returns a special axis that is used to hold all unused hierarchies. (We may change this behavior in future.)
- Parameters:
axis
- Axis type- Returns:
- Query axis
-
getAxes
Returns a map of the current query's axis.Be aware that modifications to this list might have unpredictable consequences.
- Returns:
- A standard Map object that represents the current query's axis.
-
getUnusedAxis
Returns the fictional axis into which all unused dimensions are stored. All dimensions included in this axis will not be part of the query.- Returns:
- The QueryAxis representing dimensions that are currently not used inside the query.
-
tearDown
public void tearDown(boolean closeConnection) Safely disposes of all underlying objects of this query.- Parameters:
closeConnection
- Whether or not to call theConnection.close()
method of the underlying connection.
-
tearDown
public void tearDown()Safely disposes of all underlying objects of this query and closes the underlyingOlapConnection
.Equivalent of calling Query.tearDown(true).
-
validate
Validates the current query structure. If a dimension axis has been placed on an axis but no selections were performed on it, the default hierarchy and default member will be selected. This can be turned off by invoking thesetSelectDefaultMembers(boolean)
method.- Throws:
OlapException
- If the query is not valid, an exception will be thrown and it's message will describe exactly what to fix.
-
execute
Executes the query against the current OlapConnection and returns a CellSet object representation of the data.- Returns:
- A proper CellSet object that represents the query execution results.
- Throws:
OlapException
- If something goes sour, an OlapException will be thrown to the caller. It could be caused by many things, like a stale connection. Look at the root cause for more details.
-
getName
Returns this query's name. There is no guarantee that it is unique and is set at object instanciation.- Returns:
- This query's name.
-
getLocale
Returns the current locale with which this query is expressed.- Returns:
- A standard Locale object.
-
setSelectDefaultMembers
public void setSelectDefaultMembers(boolean selectDefaultMembers) Behavior setter for a query. By default, if a dimension is placed on an axis but no selections are made, the default hierarchy and the default member will be selected when validating the query. This behavior can be turned off by this setter.- Parameters:
selectDefaultMembers
- Enables or disables the default member and hierarchy selection upon validation.
-
addQueryNodeListener
-
removeQueryNodeListener
-