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

The following examples show how to use org.apache.ignite.configuration.CacheConfiguration#getQueryEntities() . 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: IgniteDecimalSelfTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * @param tabName Table name.
 * @return QueryEntity of table.
 */
private QueryEntity findTableInfo(String tabName) {
    IgniteEx ignite = grid(0);

    Collection<String> cacheNames = ignite.cacheNames();
    for (String cacheName : cacheNames) {
        CacheConfiguration ccfg = ignite.cache(cacheName).getConfiguration(CacheConfiguration.class);

        Collection<QueryEntity> entities = ccfg.getQueryEntities();

        for (QueryEntity entity : entities)
            if (entity.getTableName().equalsIgnoreCase(tabName))
                return entity;
    }

    return null;
}
 
Example 2
Source File: IgniteDatastoreProvider.java    From hibernate-ogm-ignite with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Finds key type name for cache for entities with composite id
 * @param keyMetadata
 * @return
 */
private String findKeyType(EntityKeyMetadata keyMetadata) {
	String result = compositeIdTypes.get( keyMetadata.getTable() );
	if ( result == null ) {
		String cacheType = getEntityTypeName( keyMetadata.getTable() );
		IgniteCache<Object, BinaryObject> cache = getEntityCache( keyMetadata );
		CacheConfiguration cacheConfig = cache.getConfiguration( CacheConfiguration.class );
		if ( cacheConfig.getQueryEntities() != null ) {
			for ( QueryEntity qe : (Collection<QueryEntity>) cacheConfig.getQueryEntities() ) {
				if ( qe.getValueType() != null && cacheType.equalsIgnoreCase( qe.getValueType() ) ) {
					result = qe.getKeyType();
					break;
				}
			}
		}
		if ( result == null ) {
			if ( cacheConfig.getKeyType() != null ) {
				result = cacheConfig.getKeyType().getSimpleName();
			}
			if ( result == null ) {
				// if nothing found we use id field name
				result = StringHelper.stringBeforePoint( keyMetadata.getColumnNames()[0] );
				result = capitalize( result );
			}
		}
		compositeIdTypes.put( keyMetadata.getTable(), result );
	}
	return result;
}
 
Example 3
Source File: IgniteTestHelper.java    From hibernate-ogm-ignite with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static Set<QueryIndex> getIndexes(OgmSessionFactory sessionFactory, Class<?> entityClass) {
	Set<QueryIndex> result = new HashSet<>();
	CacheConfiguration<Object, BinaryObject> cacheConfig = getCacheConfiguration( sessionFactory, entityClass );
	for ( QueryEntity queryEntity : cacheConfig.getQueryEntities() ) {
		result.addAll( queryEntity.getIndexes() );
	}
	return result;
}
 
Example 4
Source File: IgniteTestHelper.java    From hibernate-ogm-ignite with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static Map<String, String> getFields(OgmSessionFactory sessionFactory, Class<?> entityClass) {
	Map<String, String> result = new LinkedHashMap<>();
	CacheConfiguration<Object, BinaryObject> cacheConfig = getCacheConfiguration( sessionFactory, entityClass );
	for ( QueryEntity queryEntity : cacheConfig.getQueryEntities() ) {
		result.putAll( queryEntity.getFields() );
	}
	return result;
}
 
Example 5
Source File: StoredCacheData.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * Constructor.
 *
 * @param ccfg Cache configuration.
 */
public StoredCacheData(CacheConfiguration<?, ?> ccfg) {
    A.notNull(ccfg, "ccfg");

    this.ccfg = ccfg;
    this.qryEntities = ccfg.getQueryEntities();
}