我已在schema-import参考演示示例,为我的数据库实施了预加载和 readThrough 操作。我在Apache中点击 readThrough 操作时遇到以下错误。我正在尝试从oracle数据库中读取数据。我能够从数据库中预加载数据,但在阅读记录时,我遇到了以下错误。
[18:50:42,299][SEVERE][sys-#97%null%][GridPartitionedSingleGetFuture] Failed to get values from dht cache [fut=GridCompoundIdentityFuture [super=GridCompoundFuture [rdc=Collection reducer: null, initFlag=1, lsnrCalls=0, done=true, cancelled=false, err=class o.a.i.IgniteCheckedException: javax.cache.CacheException: Failed to find mapping description [cache=WarehouseCache, typeId=class WarehouseKey]. Please configure JdbcType to associate cache 'WarehouseCache' with JdbcPojoStore., futs=[false]]]]
class org.apache.ignite.IgniteCheckedException: javax.cache.CacheException: Failed to find mapping description [cache=WarehouseCache, typeId=class WarehouseKey]. Please configure JdbcType to associate cache 'WarehouseCache' with JdbcPojoStore.
at org.apache.ignite.internal.processors.cache.store.GridCacheStoreManagerAdapter.loadFromStore(GridCacheStoreManagerAdapter.java:337)
at org.apache.ignite.internal.processors.cache.store.GridCacheStoreManagerAdapter.load(GridCacheStoreManagerAdapter.java:293)
at org.apache.ignite.internal.processors.cache.store.GridCacheStoreManagerAdapter.loadAllFromStore(GridCacheStoreManagerAdapter.java:426)
at org.apache.ignite.internal.processors.cache.store.GridCacheStoreManagerAdapter.loadAll(GridCacheStoreManagerAdapter.java:392)
at org.apache.ignite.internal.processors.cache.GridCacheAdapter$16.call(GridCacheAdapter.java:1985)
at org.apache.ignite.internal.processors.cache.GridCacheAdapter$16.call(GridCacheAdapter.java:1983)
at org.apache.ignite.internal.util.IgniteUtils.wrapThreadLoader(IgniteUtils.java:6521)
at org.apache.ignite.internal.processors.closure.GridClosureProcessor$2.body(GridClosureProcessor.java:922)
at org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:110)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: javax.cache.integration.CacheLoaderException: javax.cache.CacheException: Failed to find mapping description [cache=WarehouseCache, typeId=class WarehouseKey]. Please configure JdbcType to associate cache 'WarehouseCache' with JdbcPojoStore.
... 12 more
Caused by: javax.cache.CacheException: Failed to find mapping description [cache=WarehouseCache, typeId=class WarehouseKey]. Please configure JdbcType to associate cache 'WarehouseCache' with JdbcPojoStore.
at org.apache.ignite.cache.store.jdbc.CacheAbstractJdbcStore.entryMapping(CacheAbstractJdbcStore.java:693)
at org.apache.ignite.cache.store.jdbc.CacheAbstractJdbcStore.load(CacheAbstractJdbcStore.java:813)
at org.apache.ignite.internal.processors.cache.CacheStoreBalancingWrapper.load(CacheStoreBalancingWrapper.java:97)
at org.apache.ignite.internal.processors.cache.store.GridCacheStoreManagerAdapter.loadFromStore(GridCacheStoreManagerAdapter.java:326)
... 11 more
[18:50:42] Ignite node stopped OK [uptime=00:00:02:031]
Exception in thread "main" javax.cache.integration.CacheLoaderException: javax.cache.CacheException: Failed to find mapping description [cache=WarehouseCache, typeId=class WarehouseKey]. Please configure JdbcType to associate cache 'WarehouseCache' with JdbcPojoStore.
at org.apache.ignite.internal.processors.cache.store.GridCacheStoreManagerAdapter.loadFromStore(GridCacheStoreManagerAdapter.java:337)
at org.apache.ignite.internal.processors.cache.store.GridCacheStoreManagerAdapter.load(GridCacheStoreManagerAdapter.java:293)
at org.apache.ignite.internal.processors.cache.store.GridCacheStoreManagerAdapter.loadAllFromStore(GridCacheStoreManagerAdapter.java:426)
at org.apache.ignite.internal.processors.cache.store.GridCacheStoreManagerAdapter.loadAll(GridCacheStoreManagerAdapter.java:392)
at org.apache.ignite.internal.processors.cache.GridCacheAdapter$16.call(GridCacheAdapter.java:1985)
at org.apache.ignite.internal.processors.cache.GridCacheAdapter$16.call(GridCacheAdapter.java:1983)
at org.apache.ignite.internal.util.IgniteUtils.wrapThreadLoader(IgniteUtils.java:6521)
at org.apache.ignite.internal.processors.closure.GridClosureProcessor$2.body(GridClosureProcessor.java:922)
at org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:110)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: javax.cache.CacheException: Failed to find mapping description [cache=WarehouseCache, typeId=class WarehouseKey]. Please configure JdbcType to associate cache 'WarehouseCache' with JdbcPojoStore.
at org.apache.ignite.cache.store.jdbc.CacheAbstractJdbcStore.entryMapping(CacheAbstractJdbcStore.java:693)
at org.apache.ignite.cache.store.jdbc.CacheAbstractJdbcStore.load(CacheAbstractJdbcStore.java:813)
at org.apache.ignite.internal.processors.cache.CacheStoreBalancingWrapper.load(CacheStoreBalancingWrapper.java:97)
at org.apache.ignite.internal.processors.cache.store.GridCacheStoreManagerAdapter.loadFromStore(GridCacheStoreManagerAdapter.java:326)
... 11 more
我使用了以下CacheConfig文件,
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.sql.*;
import java.util.*;
import org.apache.ignite.cache.*;
import org.apache.ignite.cache.store.jdbc.*;
import org.apache.ignite.configuration.*;
/**
* CacheConfig definition.
*
* Code generated by Apache Ignite Schema Import utility: 10/21/2016.
*/
public class CacheConfig {
/**
* Create JDBC type for WAREHOUSE.
*
* @param cacheName Cache name.
* @return Configured JDBC type.
*/
private static JdbcType jdbcTypeWarehouse(String cacheName) {
JdbcType jdbcType = new JdbcType();
jdbcType.setCacheName(cacheName);
jdbcType.setDatabaseSchema("C##TPCCTEST");
jdbcType.setDatabaseTable("WAREHOUSE");
jdbcType.setKeyType("org.apache.ignite.WarehouseKey");
jdbcType.setValueType("org.apache.ignite.Warehouse");
// Key fields for WAREHOUSE.
Collection<JdbcTypeField> keys = new ArrayList<>();
keys.add(new JdbcTypeField(Types.INTEGER, "W_ID", int.class, "wId"));
jdbcType.setKeyFields(keys.toArray(new JdbcTypeField[keys.size()]));
// Value fields for WAREHOUSE.
Collection<JdbcTypeField> vals = new ArrayList<>();
vals.add(new JdbcTypeField(Types.INTEGER, "W_ID", int.class, "wId"));
vals.add(new JdbcTypeField(Types.VARCHAR, "W_NAME", String.class, "wName"));
vals.add(new JdbcTypeField(Types.VARCHAR, "W_STREET_1", String.class, "wStreet1"));
vals.add(new JdbcTypeField(Types.VARCHAR, "W_STREET_2", String.class, "wStreet2"));
vals.add(new JdbcTypeField(Types.VARCHAR, "W_CITY", String.class, "wCity"));
vals.add(new JdbcTypeField(Types.CHAR, "W_STATE", String.class, "wState"));
vals.add(new JdbcTypeField(Types.CHAR, "W_ZIP", String.class, "wZip"));
vals.add(new JdbcTypeField(Types.FLOAT, "W_TAX", Double.class, "wTax"));
vals.add(new JdbcTypeField(Types.FLOAT, "W_YTD", Double.class, "wYtd"));
jdbcType.setValueFields(vals.toArray(new JdbcTypeField[vals.size()]));
return jdbcType;
}
/**
* Create SQL Query descriptor for WAREHOUSE.
*
* @return Configured query entity.
*/
private static QueryEntity queryEntityWarehouse() {
QueryEntity qryEntity = new QueryEntity();
qryEntity.setKeyType("org.apache.ignite.WarehouseKey");
qryEntity.setValueType("org.apache.ignite.Warehouse");
// Query fields for WAREHOUSE.
LinkedHashMap<String, String> fields = new LinkedHashMap<>();
fields.put("wId", "java.lang.Integer");
fields.put("wName", "java.lang.String");
fields.put("wStreet1", "java.lang.String");
fields.put("wStreet2", "java.lang.String");
fields.put("wCity", "java.lang.String");
fields.put("wState", "java.lang.String");
fields.put("wZip", "java.lang.String");
fields.put("wTax", "java.lang.Double");
fields.put("wYtd", "java.lang.Double");
qryEntity.setFields(fields);
// Aliases for fields.
Map<String, String> aliases = new HashMap<>();
aliases.put("wId", "W_ID");
aliases.put("wName", "W_NAME");
aliases.put("wStreet1", "W_STREET_1");
aliases.put("wStreet2", "W_STREET_2");
aliases.put("wCity", "W_CITY");
aliases.put("wState", "W_STATE");
aliases.put("wZip", "W_ZIP");
aliases.put("wTax", "W_TAX");
aliases.put("wYtd", "W_YTD");
qryEntity.setAliases(aliases);
// Indexes for WAREHOUSE.
Collection<QueryIndex> idxs = new ArrayList<>();
idxs.add(new QueryIndex("wId", true, "SYS_C0011180"));
qryEntity.setIndexes(idxs);
return qryEntity;
}
/**
* Configure cache.
*
* @param cacheName Cache name.
* @param storeFactory Cache store factory.
* @return Cache configuration.
*/
public static <K, V> CacheConfiguration<K, V> cache(String cacheName, CacheJdbcPojoStoreFactory<K, V> storeFactory) {
if (storeFactory == null)
throw new IllegalArgumentException("Cache store factory cannot be null.");
CacheConfiguration<K, V> ccfg = new CacheConfiguration<>(cacheName);
ccfg.setCacheStoreFactory(storeFactory);
ccfg.setReadThrough(true);
ccfg.setWriteThrough(true);
// Configure JDBC types.
Collection<JdbcType> jdbcTypes = new ArrayList<>();
jdbcTypes.add(jdbcTypeWarehouse(cacheName));
storeFactory.setTypes(jdbcTypes.toArray(new JdbcType[jdbcTypes.size()]));
// Configure query entities.
Collection<QueryEntity> qryEntities = new ArrayList<>();
qryEntities.add(queryEntityWarehouse());
ccfg.setQueryEntities(qryEntities);
return ccfg;
}
}