Class GenericMapLoader<K,V>

java.lang.Object
com.hazelcast.mapstore.GenericMapLoader<K,V>
Type Parameters:
K - type of the key
V - type of the value
All Implemented Interfaces:
MapLoader<K,V>, MapLoaderLifecycleSupport
Direct Known Subclasses:
GenericMapStore

public class GenericMapLoader<K,V> extends Object implements MapLoader<K,V>, MapLoaderLifecycleSupport
GenericMapLoader is an implementation of MapLoader built on top of Hazelcast SQL engine.

It works with any SQL connector supporting SELECT statements.

Usage:

First define data connection, e.g. for JDBC use JdbcDataConnection:

Config config = new Config();
 config.addDataConnectionConfig(
   new DataConnectionConfig("mysql-ref")
     .setType("Jdbc")
     .setProperty("jdbcUrl", dbConnectionUrl)
 );

Then create a Map with MapLoader using the GenericMapLoader implementation:

MapConfig mapConfig = new MapConfig(mapName);
 MapStoreConfig mapStoreConfig = new MapStoreConfig();
 mapStoreConfig.setClassName(GenericMapLoader.class.getName());
 mapStoreConfig.setProperty(GenericMapLoader.DATA_CONNECTION_REF_PROPERTY, "mysql-ref");
 mapConfig.setMapStoreConfig(mapStoreConfig);
 instance().getConfig().addMapConfig(mapConfig);

The GenericMapLoader creates a SQL mapping with name "__map-store." + mapName. This mapping is removed when the map is destroyed.