BigMemory Go 4.3.4 | Product Documentation | BigMemory Go Developer Guide | Searching with BigMemory SQL | SQL Syntax and Examples | FROM Clause
FROM Clause
By default, the QueryManager locates the cache name attached to the FROM clause from all CacheManagers specified when the QueryManager was built.
... from [ Cache | CacheManager.Cache ] ...
If there are multiple CacheManagers, two or more might have a cache with the same name. For example, suppose that in addition to the ehcache-users.xml configuration (presented in Using BigMemory SQL), there is another configuration file called ehcache-address.xml that provides detailed address information.
<ehcache name="Detailed-Address">
<!--another cache with the name "Address" is present in ehcache-users.xml-->
<cache name="Address">
<searchAttribute name="name" type="String" expression="value.getName()"/>
<searchAttribute name="street" type="String" expression="value.getStreet()"/>
<searchAttribute name="apartment" type="String" expression="value.getApartment()"/>
<searchAttribute name="city" type="String" expression="value.getCity()"/>
<searchAttribute name="zip" type="int" expression="value.getZip()"/>
Because more than one cache has the name Address, we prefix the CacheManager name, that is, Users.Address or Detailed-Address.Address:
// get cache managers
CacheManager usersCacheManager = new CacheManager("ehcache-users.xml");
CacheManager addressCacheManager = new CacheManager("ehcache-address.xml");
// needed only once
QueryManager qm = QueryManagerBuilder.newQueryManagerBuilder()
// ** Default use case
// Since the Person cache is unique, we don't need to supply the cache manager
Query nameQuery1 = qm.createQuery("select name from Person where age > 21");
// ** Explicit scoping use case #1
// search Address cache defined in ehcache-users.xml where the CacheManager name is "Users"
Query nameQuery2 = qm.createQuery("select name from Users.Address where zip = 94115");
// ** Explicit scoping use case #2
// search Address cache defined in ehcache-address.xml where the CacheManager name
// is "Detailed-Address"
Query nameQuery3 = qm.createQuery("select name from Detailed-Address.Address
where zip = 94115");
// get the results
Results allNamesInUserRecordsOver21 = nameQuery1.end().execute();
Results allNamesInUserRecordsIn94115 = nameQuery2.end().execute();
Results allNamesInAddressBookIn94115 = nameQuery3.end().execute();
// iterate over the results, etc.
Note: If no CacheManager is specified in the FROM clause, and multiple caches with the same name are found, an exception is thrown with a message that more than one cache with the same name exists.

Copyright © 2010 - 2019 | Software AG, Darmstadt, Germany and/or Software AG USA, Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors.
Innovation Release