Java Code Examples for org.apache.ignite.configuration.CacheConfiguration#setSqlEscapeAll()

The following examples show how to use org.apache.ignite.configuration.CacheConfiguration#setSqlEscapeAll() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IgnitePersistentStoreSchemaLoadTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * Create node configuration with a cache pre-configured.
 * @param gridName Node name.
 * @return Node configuration with a cache pre-configured.
 * @throws Exception if failed.
 */
@SuppressWarnings("unchecked")
private IgniteConfiguration getConfigurationWithStaticCache(String gridName) throws Exception {
    IgniteConfiguration cfg = getConfiguration(gridName);

    CacheConfiguration ccfg = cacheCfg(STATIC_CACHE_NAME);

    ccfg.setIndexedTypes(Integer.class, Person.class);
    ccfg.setSqlEscapeAll(true);

    cfg.setCacheConfiguration(ccfg);

    return optimize(cfg);
}
 
Example 2
Source File: H2DynamicTableSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @return Default cache configuration.
 */
private CacheConfiguration cacheConfiguration() {
    CacheConfiguration<?, ?> ccfg = new CacheConfiguration<>(CACHE_NAME);

    ccfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    ccfg.setSqlEscapeAll(true);
    ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
    ccfg.setCacheMode(CacheMode.PARTITIONED);

    return ccfg;
}
 
Example 3
Source File: H2DynamicIndexAbstractSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @return Default cache configuration.
 */
private CacheConfiguration cacheConfiguration() {
    CacheConfiguration<KeyClass, ValueClass> ccfg = new CacheConfiguration<KeyClass, ValueClass>()
        .setName(CACHE_NAME);

    QueryEntity entity = new QueryEntity();

    entity.setKeyType(KeyClass.class.getName());
    entity.setValueType(ValueClass.class.getName());

    entity.addQueryField("id", Long.class.getName(), null);
    entity.addQueryField(FIELD_NAME_1_ESCAPED, Long.class.getName(), null);
    entity.addQueryField(FIELD_NAME_2_ESCAPED, Long.class.getName(), null);

    entity.setKeyFields(Collections.singleton("id"));

    entity.setAliases(Collections.singletonMap(FIELD_NAME_2_ESCAPED, alias(FIELD_NAME_2_ESCAPED)));

    ccfg.setQueryEntities(Collections.singletonList(entity));

    ccfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    ccfg.setSqlEscapeAll(true);
    ccfg.setAtomicityMode(atomicityMode());
    ccfg.setCacheMode(cacheMode());

    if (nearCache())
        ccfg.setNearConfiguration(new NearCacheConfiguration<KeyClass, ValueClass>());

    return ccfg;
}
 
Example 4
Source File: IgniteCacheJoinQueryWithAffinityKeyTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/**
 * @param cacheMode Cache mode.
 * @param backups Number of backups.
 * @param affKey If {@code true} uses key with affinity key field.
 * @param includeAffKey If {@code true} includes affinity key field in query fields.
 * @return Cache configuration.
 */
private CacheConfiguration cacheConfiguration(CacheMode cacheMode,
    int backups,
    boolean affKey,
    boolean includeAffKey) {
    CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);

    ccfg.setCacheMode(cacheMode);

    if (cacheMode == PARTITIONED)
        ccfg.setBackups(backups);

    ccfg.setWriteSynchronizationMode(FULL_SYNC);

    String personKeyType = affKey ? TestKeyWithAffinity.class.getName() : TestKey.class.getName();

    QueryEntity account = new QueryEntity();
    account.setKeyType(Integer.class.getName());
    account.setValueType(affKey ? AccountKeyWithAffinity.class.getName() : Account.class.getName());
    account.addQueryField("personKey", personKeyType, null);
    account.addQueryField("personId", Integer.class.getName(), null);
    account.setIndexes(F.asList(new QueryIndex("personKey"), new QueryIndex("personId")));

    QueryEntity person = new QueryEntity();
    person.setKeyType(personKeyType);
    person.setValueType(Person.class.getName());
    person.setKeyFields(Collections.singleton("id"));
    person.addQueryField("orgId", Integer.class.getName(), null);
    person.addQueryField("id", Integer.class.getName(), null);
    person.addQueryField("name", String.class.getName(), null);
    person.setIndexes(F.asList(new QueryIndex("orgId"), new QueryIndex("id"), new QueryIndex("name")));

    if (affKey && includeAffKey)
        person.addQueryField("affKey", Integer.class.getName(), null);

    QueryEntity org = new QueryEntity();
    org.setKeyType(Integer.class.getName());
    org.setValueType(Organization.class.getName());
    org.addQueryField("name", String.class.getName(), null);
    org.setIndexes(F.asList(new QueryIndex("name")));

    ccfg.setQueryEntities(F.asList(account, person, org));

    ccfg.setSqlEscapeAll(escape);

    return ccfg;
}