can we make generic class for cachehibernatepojostore?

classic Classic list List threaded Threaded
4 messages Options
Ravi Puri Ravi Puri
Reply | Threaded
Open this post in threaded view
|

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??
       
vkulichenko vkulichenko
Reply | Threaded
Open this post in threaded view
|

Re: can we make generic class for cachehibernatepojostore?

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
Ravi Puri Ravi Puri
Reply | Threaded
Open this post in threaded view
|

Re: can we make generic class for cachehibernatepojostore?

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" <[hidden email]> 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.
vkulichenko vkulichenko
Reply | Threaded
Open this post in threaded view
|

Re: can we make generic class for cachehibernatepojostore?

Can you show the whole exception trace?

-Val