【问题标题】:How to load 2 database tables into the same Gridgain cache如何将 2 个数据库表加载到同一个 Gridgain 缓存中
【发布时间】:2016-04-10 22:43:57
【问题描述】:

我想加载到缓存中的数据库中有两个表部门(dept_id 和部门)和雇员(emp_id,dept_id,名字,姓氏)。我使用了模式导入工具,它生成了 CacheConfig.java、DepartmentKey.java、Department.java、Employee.java 和 EmployeeKey.java 文件。现在现在我如何用这两个表加载缓存?

这是sn-p:

 private static class MySQLDemoStoreFactory<K, V> extends CacheJdbcPojoStoreFactory<K, V> { 
         //{@inheritDoc} 
         @Override public CacheJdbcPojoStore<K, V> create() { 


            MysqlDataSource dataSource = new MysqlDataSource(); 
            dataSource.setURL("jdbc:mysql://localhost/DB"); 
            dataSource.setUser("root"); 
            dataSource.setPassword("pass"); 
            setDataSource(dataSource); 
            return super.create(); 

        } 

    } 

然后在main中,加载缓存:

try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) { 
            // Configure cache store. 
            CacheConfiguration<EmployeeKey, Employee> cfg = 
                CacheConfig.cache("EmpCache", new MySQLDemoStoreFactory<EmployeeKey, Employee>()); 

            try (IgniteCache<EmployeeKey, Employee> cache = ignite.getOrCreateCache(cfg)) { 
                // Preload cache from database. 
                preload(cache); 

这只会将它与 Employee 表一起加载,对吗?如何同时加载 Department 和 Employee 表?

【问题讨论】:

    标签: java database caching gridgain


    【解决方案1】:

    我相信这个问题已在此处的 Ignite 用户列表中得到解答:

    http://apache-ignite-users.70518.x6.nabble.com/How-to-load-2-tables-in-a-cache-td4026.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-04-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-11-01
      • 1970-01-01
      相关资源
      最近更新 更多