You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by Ravi Puri <ra...@gmail.com> on 2016/04/20 08:50:55 UTC

can we make generic class for cachehibernatepojostore?

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.

Re: can we make generic class for cachehibernatepojostore?

Posted by vkulichenko <va...@gmail.com>.
Can you show the whole exception trace?

-Val



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

Re: can we make generic class for cachehibernatepojostore?

Posted by Ravi kumar Puri <ra...@gmail.com>.
I didnt get u... u mean i have to add cachehibernatestore to client
classpath class.

And how can i load it to all d nodes?
As i use only one server n one node
On 21-Apr-2016 00:24, "vkulichenko" <va...@gmail.com> wrote:

> Hi Ravi,
>
> Currently you need to have the cache store implementation class on all
> nodes. So you need to add CacheHibernatePersonStore on client's classpath
> to
> make it work.
>
> -Val
>
>
>
> --
> View this message in context:
> http://apache-ignite-users.70518.x6.nabble.com/can-we-make-generic-class-for-cachehibernatepojostore-tp4355p4383.html
> Sent from the Apache Ignite Users mailing list archive at Nabble.com.
>

Re: can we make generic class for cachehibernatepojostore?

Posted by vkulichenko <va...@gmail.com>.
Hi Ravi,

Currently you need to have the cache store implementation class on all
nodes. So you need to add CacheHibernatePersonStore on client's classpath to
make it work.

-Val



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