Product Documentation : BigMemory Go Developer Guide : Searching with BigMemory SQL : Using BigMemory SQL
Using BigMemory SQL
Configure the Ehcache File
Confirm that the search configuration sub-elements are present in your ehcache.xml file. To enable searching the cache with BigMemory SQL, include the <searchable/> tag. To enable the addition of search attributes after the cache is initialized, include the allowDynamicIndexing option.
This example defines the searchable cache's configuration in an ehcache.xml file called ehcache-users.xml.
<ehcache name="Users">
<cache name="Person">
<searchable allowDynamicIndexing="true">
<searchAttribute name="name" type="String" expression="value.getName()"/>
<searchAttribute name="age" type="int" expression="value.getAge()"/>
</searchable>
</cache>
<cache name="Address">
<searchable>
<searchAttribute name="zip" type="int" expression="value.address.getZip()"/>
</searchable>
</cache>
</ehcache>
Instantiate the QueryManager
In your application, instantiate the QueryManager using the QueryManagerBuilder.
// get the CacheManager that contains the caches to query
CacheManager usersCacheManager = new CacheManager("ehcache-users.xml");
// build the QueryManager
QueryManager queryManager = QueryManagerBuilder
.newQueryManagerBuilder()
.addCache(Person)
.addCache(Address)
.build();
For more information about this step, see About Searching.
Issue a Query
Issue the BigMemory SQL query.
// construct the queries
Query personQuery = queryManager.createQuery("select * from Person where age > 30");
Query addressQuery = queryManager.createQuery("select zip from Address where zip = 94115");
// execute the queries
Results personResults = personQuery.end().execute();
Results addressResults = addressQuery.end().execute();
// iterate over the results, etc.
For more information about specifying a SQL query, see SQL Syntax and Examples.
Copyright © 2010-2017 Software AG, Darmstadt, Germany.

Product LogoContact Support   |   Community   |   Feedback