Open topic with navigation

TIBCO BusinessEvents® Enterprise Edition 6.3.1

## Native Queries

You can use native query to improve the query performance. Native queries are run directly on the cache or store provider that is configured in the project CDD. Native querying is supported for Apache Ignite.

A native query by default returns EntityType results that are the same as a BQL query. All the functions including column name and type are the same as a BQL query.

For a native query to return EntityType results, a new parameter `isNativeQueryRawResults` is added. The default value of this parameter is false.

On importing the projects from older BusinessEvents versions, prior to version 6.3.1, a native query returns raw results. So, the value of `isNativeQueryRawResults` parameter is true for imported projects. However, the native query can be set to return the EntityType results by setting this parameter to false in the following `Query` catalog functions:

- Query.Util.executeInDynamicQuerySession()
- Query.Util.executeInQuerySession()
- Query.create()

For details about the functions, see TIBCO BusinessEvents Event Stream Processing Query Developer’s Guide.

A schema name can be provided in a native query unlike a BQL query. For example,

    select * from NATIVEQEXT.BE_GEN_Concepts_Common_Customer as cu where cu.age=4";
    Schema name: NATIVEQEXT

In the Query.ResultSet.get() method to get columns for complex columnTypes, such as Contained concept or Reference concept or Array returns the same results as a BQL query. For example, the Get() method for the Contained concept returns the Concept object and the columnType returns the EntityType results.

The following table describes the property that can be used to modify the native query results if required:

Properties | Returns | Description
--- | --- | ---
`be.engine.native.query.getAll.columns` | Boolean | To view all the columns including those which are not part of the Ignite Entity properties, set the value of the property to `true`. The default value is `false`. For example, _parentId, _rrf, and _version. Note: The columns that are not part of the Ignite Entity properties are excluded in a BQL query. So, they are excluded in Native queries too.

To use native querying, prefix the usual query with the `native-query:` string:

    native-query: SELECT column1, column2 FROM table_name;

For example, refer to the following native query example with the Apache Ignite as a cache provider:

Original Query | Native Query
--- | ---
`SELECT age, count FROM /Concepts/Common/Customer;` | `native-query: SELECT age, count FROM be_gen_Concepts_Common_Customer;`

Note:

- The tables must be present internally with the provider in use.
- The native query format must conform to the query syntax of the provider in use.
- Native queries work from both the BQL console and project code.
- Native queries only work for snapshot queries.
- Native queries run on the cache for cache object management mode irrespective of the persistence configuration.
- For limited cache, native queries run on the limited records that are available in the cache.
- If the `be.engine.native.query.rawResults.enabled` property is set to `false`, the DISTINCT, GROUP BY, and aggregate functions are not supported.

Did you find this helpful?

YesNo
Great!
Thanks for taking the time to give us some feedback.
Sorry about that

Why wasn't this helpful? (check all that apply)

Could not find what I was looking for
Instructions confusing or unclear
Instructions did not work

Want to tell us more?

Please select at least one option or provide details about the issue!!

Error occurred while submitting feedback.

Error2 occurred while submitting feedback.

TIBCO BusinessEvents® Enterprise Edition

Copyright © 2004-2024. Cloud Software Group, Inc. All Rights Reserved.