'setIndexedTypes seems to be ignored when the cache configuration is set with a template

I am getting the following exception when querying a cache

javax.cache.CacheException: Indexing is disabled for cache: DEFAULT. Use setIndexedTypes or setTypeMetadata methods on CacheConfiguration to enable.

The cache configuration is set using a template

    // template for cache configurations
    CacheConfiguration cacheCfg = new CacheConfiguration("cacheTemplate");
    cacheCfg.setBackups(backups);
    cacheCfg.setCacheMode(CacheMode.PARTITIONED);
    cacheCfg.setIndexedTypes(Key.class, Payload.class);

    ignite.addCacheConfiguration(cacheCfg);

Shouldn't that work? Or do I need to set the configuration explicitely, in which case, what is the point of having a template?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source