ignite-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ravi Puri <ravikumarpur...@gmail.com>
Subject can we make generic class for cachehibernatepojostore?
Date Wed, 20 Apr 2016 06:50:55 GMT
i have a query 

i have one class which loads cacheconfiguration class(CacheConfig) with its
cachehibernatepojostore(specific to class) passed in factory builder which i
passed as T.


public class CacheConfig {

	private static final long serialVersionUID = 1L;
	private static final String HIBERNATE_CFG = "hibernate.cfg.xml";

	@SuppressWarnings({ "unchecked", "rawtypes" })
	public static CacheConfiguration<String, Class> loadConfig(String
CacheName,
			 Class  T) {
		CacheConfiguration<String, Class> cacheCfg = new
CacheConfiguration<>(p_strCacheName
				);

		// Set atomicity as transaction, since we are showing transactions in
		// example.
		cacheCfg.setAtomicityMode(TRANSACTIONAL);

		// Configure JDBC store.
		cacheCfg.setCacheStoreFactory(FactoryBuilder.factoryOf(T));

		// Configure hibernate session listener.
		cacheCfg.setCacheStoreSessionListenerFactories(new
Factory<CacheStoreSessionListener>() {
			/**
			 * 
			 */
			private static final long serialVersionUID = 1L;

			@Override
			public CacheStoreSessionListener create() {
				CacheHibernateStoreSessionListener lsnr = new
CacheHibernateStoreSessionListener();

				lsnr.setHibernateConfigurationPath(HIBERNATE_CFG);

				return lsnr;
			}
		});

		cacheCfg.setReadThrough(true);
		cacheCfg.setWriteThrough(true);
		
		System.out.println("ended configuration loadConfig");

		return cacheCfg;
	}
	
}


so form main i can access
CacheConfig objCacheConfig = new CacheConfig();
	IgniteCache<String, Class> cache= objCacheConfig .loadConfig("CacheName",
CacheHibernatePersonStore .class);
		cache.loadCache(null, 100_00);


IT LOAD ALL DATA RELATED TO CacheHibernatePersonStore extends
CacheStoreAdapter<Integer, Person>
means in short it load all the data to server side



now m using client side and has different ignite.xml 

now i want to access the data to this client side in different package of
eclipse which was loaded in server side with different config.(as m able to
connect server and client is connected )
but when m trying to fetch it shows
error:
Failed to create an instance of CacheHibernatePersonStore class
	

how can i able to load it??
	



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/can-we-make-generic-class-for-cachehibernatepojostore-tp4355.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Mime
View raw message