/** * @param stmt Prepare statement. * @param idx Start index for parameters. * @param em Entry mapping. * @param key Key object. * @return Next index for parameters. * @throws CacheException If failed to set statement parameters. */ protected int fillKeyParameters(PreparedStatement stmt, int idx, EntryMapping em, Object key) throws CacheException { for (JdbcTypeField field : em.keyColumns()) { Object fieldVal = extractParameter(em.cacheName, em.keyType(), em.keyKind(), field.getJavaFieldName(), key); fillParameter(stmt, idx++, field, fieldVal); } return idx; }
/** * Gets value columns. * * @return Value columns. */ protected JdbcTypeField[] valueColumns() { return typeMeta.getValueFields(); }
/** * @param stmt Prepare statement. * @param m Type mapping description. * @param key Key object. * @return Next index for parameters. * @throws CacheException If failed to set statement parameters. */ protected int fillKeyParameters(PreparedStatement stmt, EntryMapping m, Object key) throws CacheException { return fillKeyParameters(stmt, 1, m, key); }
/** */ public JdbcType getJdbcType() { JdbcType type = new JdbcType(); type.setCacheName("TEST_CACHE"); type.setKeyType(Integer.class); type.setValueType(TestPojo.class); type.setDatabaseSchema("PUBLIC"); type.setDatabaseTable("TEST_CACHE"); type.setKeyFields(new JdbcTypeField(java.sql.Types.INTEGER, "VALUE2", Integer.class, "value2")); type.setValueFields( new JdbcTypeField(java.sql.Types.VARCHAR, "VALUE1", String.class, "value1"), new JdbcTypeField(java.sql.Types.DATE, "VALUE3", java.sql.Date.class, "value3") ); return type; }
/** */ public CacheJdbcPojoStoreFactory getStoreFactory() { CacheJdbcPojoStoreFactory storeFactory = new CacheJdbcPojoStoreFactory(); storeFactory.setParallelLoadCacheMinimumThreshold(100); storeFactory.setBatchSize(100); storeFactory.setMaximumPoolSize(4); storeFactory.setDataSourceFactory(getDataSourceFactory()); storeFactory.setDialect(new H2Dialect()); storeFactory.setTypes(getJdbcType()); return storeFactory; }
/** * Copy constructor. * * @param type Type to copy. */ public JdbcType(JdbcType type) { cacheName = type.getCacheName(); dbSchema = type.getDatabaseSchema(); dbTbl = type.getDatabaseTable(); keyType = type.getKeyType(); keyFields = type.getKeyFields(); valType = type.getValueType(); valFlds = type.getValueFields(); }
/** * @param stmt Prepare statement. * @param idx Start index for parameters. * @param em Type mapping description. * @param val Value object. * @return Next index for parameters. * @throws CacheException If failed to set statement parameters. */ protected int fillValueParameters(PreparedStatement stmt, int idx, EntryMapping em, Object val) throws CacheWriterException { for (JdbcTypeField field : em.uniqValFlds) { Object fieldVal = extractParameter( em.cacheName, em.valueType(), em.valueKind(), field.getJavaFieldName(), val ); fillParameter(stmt, idx++, field, fieldVal); } return idx; }
/** * Copy constructor. * * @param field Field to copy. */ public JdbcTypeField(JdbcTypeField field) { this(field.getDatabaseFieldType(), field.getDatabaseFieldName(), field.getJavaFieldType(), field.getJavaFieldName()); }
/** {@inheritDoc} */ @Override protected CacheJdbcBlobStore<Object, Object> store() { return new CacheJdbcBlobStore<>(); } }
/** * Construct load cache in one select. * * @param m Type mapping description. * @param clo Closure for loaded values. * @return Callable for pool submit. */ private Callable<Void> loadCacheFull(EntryMapping m, IgniteBiInClosure<K, V> clo) { return loadCacheRange(m, clo, null, null, dialect.getFetchSize()); }
/** * @return Value. */ public T value() { if (val == null) val = create(); return val; } }
/** {@inheritDoc} */ @Override public String apply(JdbcTypeField col) { return col.getDatabaseFieldName(); } });
/** * Gets key columns. * * @return Key columns. */ protected JdbcTypeField[] keyColumns() { return typeMeta.getKeyFields(); }
/** * @return Key type. */ protected String keyType() { return typeMeta.getKeyType(); }
/** * @return Value type. */ protected String valueType() { return typeMeta.getValueType(); }
@Override public CacheStore<Integer, Integer> create() { return new Store(); } };
/** {@inheritDoc} */ @Override protected void afterTest() throws Exception { stopAllGrids(); }
/** {@inheritDoc} */ @Override protected void afterTest() throws Exception { stopAllGrids(); }
/** {@inheritDoc} */ @Override protected void afterTest() throws Exception { stopAllGrids(); }
/** {@inheritDoc} */ @Override protected CacheStore getStore() { return new CacheJdbcBlobStore(); }