Skip navigation links

Oracle® Database XML Java API Reference 11g Release 2 (11.2) E10769-01

## javax.jcr.query
Interface Query

All Known Subinterfaces:
  OracleQuery

      public interface Query

A `Query` object.

Field Summary
`static java.lang.String` `SQL` A String constant representing the SQL query language applied to the database view of the workspace.
`static java.lang.String` `XPATH` A String constant representing the XPath query language applied to the document view XML mapping of the workspace.

Method Summary
`QueryResult` `execute()` Executes this query and returns a ``QueryResult``.
`java.lang.String` `getLanguage()` Returns the language set for this query.
`java.lang.String` `getStatement()` Returns the statement set for this query.
`java.lang.String` `getStoredQueryPath()` If this is a `Query` object that has been stored using `storeAsNode(java.lang.String)` (regardless of whether it has been `save`d yet) or retrieved using `QueryManager.getQuery(javax.jcr.Node)`), then this method returns the path of the `nt:query` node that stores the query.
`Node` `storeAsNode(java.lang.String absPath)` Creates a node representing this `Query` in content.

Field Detail

### XPATH

    static final java.lang.String XPATH

  A String constant representing the XPath query language applied to the document view XML mapping of the workspace. <p/> This language must be supported in level 1 repositories. <p/> Used when defining a query using `QueryManager.createQuery(java.lang.String, java.lang.String)`. Also among the strings returned by `QueryManager.getSupportedQueryLanguages()`.
  See Also:
    Constant Field Values

### SQL

    static final java.lang.String SQL

  A String constant representing the SQL query language applied to the database view of the workspace. <p/> This language is optional. <p/> Used when defining a query using `QueryManager.createQuery(java.lang.String, java.lang.String)`. Also among the strings returned by `QueryManager.getSupportedQueryLanguages()`.
  See Also:
    Constant Field Values

Method Detail

### execute

    QueryResult execute()
                        throws RepositoryException

  Executes this query and returns a ``QueryResult``.
  Returns:
    a `QueryResult`
  Throws:
    `RepositoryException` - if an error occurs

### getStatement

    java.lang.String getStatement()

  Returns the statement set for this query.
  Returns:
    the query statement.

### getLanguage

    java.lang.String getLanguage()

  Returns the language set for this query. This will be one of the query language constants returned by `QueryManager.getSupportedQueryLanguages()`.
  Returns:
    the query language.

### getStoredQueryPath

    java.lang.String getStoredQueryPath()
                                        throws ItemNotFoundException,
                                               RepositoryException

  If this is a `Query` object that has been stored using `storeAsNode(java.lang.String)` (regardless of whether it has been `save`d yet) or retrieved using `QueryManager.getQuery(javax.jcr.Node)`), then this method returns the path of the `nt:query` node that stores the query. If this is a transient query (that is, a `Query` object created with `QueryManager.createQuery(java.lang.String, java.lang.String)` but not yet stored) then this method throws an `ItemNotFoundException`.
  Returns:
    path of the node representing this query.
  Throws:
    `ItemNotFoundException` - if this query is not a stored query.
    `RepositoryException` - if another error occurs.

### storeAsNode

    Node storeAsNode(java.lang.String absPath)
                     throws ItemExistsException,
                            PathNotFoundException,
                            VersionException,
                            ConstraintViolationException,
                            LockException,
                            UnsupportedRepositoryOperationException,
                            RepositoryException

  Creates a node representing this `Query` in content. <p/> In a level 1 repository this method throws an `UnsupportedRepositoryOperationException`. <p/> In a level 2 repository it creates a node of type `nt:query` at `absPath` and returns that node. <p/> In order to persist the newly created node, a `save` must be performed that includes the parent of this new node within its scope. In other words, either a `Session.save` or an `Item.save` on the parent or higher-degree ancestor of `absPath` must be performed. <p/> An `ItemExistsException` will be thrown either immediately (by this method), or on `save`, if an item at the specified path already exists and same-name siblings are not allowed. Implementations may differ on when this validation is performed. <p/> A `PathNotFoundException` will be thrown either immediately , or on `save`, if the specified path implies intermediary nodes that do not exist. Implementations may differ on when this validation is performed. <p/> A `ConstraintViolationException`will be thrown either immediately or on `save`, if adding the node would violate a node type or implementation-specific constraintor if an attempt is made to add a node as the child of a property. Implementations may differ on when this validation is performed. <p/> A `VersionException` will be thrown either immediately (by this method), or on `save`, if the node to which the new child is being added is versionable and checked-in or is non-versionable but its nearest versionable ancestor is checked-in. Implementations may differ on when this validation is performed. <p/> A `LockException` will be thrown either immediately (by this method), or on `save`, if a lock prevents the addition of the node. Implementations may differ on when this validation is performed.
  Returns:
    the newly created node.
  Throws:
    `ItemExistsException` - if an item at the specified path already exists, same-name siblings are not allowed and this implementation performs this validation immediately instead of waiting until `save`.
    `PathNotFoundException` - if the specified path implies intermediary `Node`s that do not exist or the last element of `relPath` has an index, and this implementation performs this validation immediately instead of waiting until `save`.
    `ConstraintViolationException` - if a node type or implementation-specific constraint is violated or if an attempt is made to add a node as the child of a property and this implementation performs this validation immediately instead of waiting until `save`.
    `VersionException` - if the node to which the new child is being added is versionable and checked-in or is non-versionable but its nearest versionable ancestor is checked-in and this implementation performs this validation immediately instead of waiting until `save`.
    `LockException` - if a lock prevents the addition of the node and this implementation performs this validation immediately instead of waiting until `save`.
    `UnsupportedRepositoryOperationException` - in a level 1 implementation.
    `RepositoryException` - if another error occurs or if the `relPath` provided has an index on its final element.

Skip navigation links

Oracle® Database XML Java API Reference 11g Release 2 (11.2) E10769-01

Copyright © 2004-2005 Day Software Management AG. All Rights Reserved.