You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by Skollur <Sk...@idbny.com> on 2018/09/17 16:59:24 UTC
Error while loading data to cache
I am trying to load data to cache using below code and seeing an error.
ignite.cache("CustomerCache").loadCache(new IgniteBiPredicate()
{
@Override
public boolean apply(Object key, Object value) {
if(((Customer) value).getId()==1000000001);
return true;
}
});
ERROR:-
Caused by: java.lang.ClassCastException:
org.apache.ignite.internal.binary.BinaryObjectImpl cannot be cast to
com.idb.cache.model.Customer
at
com.idb.cache.load.LoadIdbIgniteCaches$1.apply(LoadIdbIgniteCaches.java:36)
at
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheAdapter.loadEntry(GridDhtCacheAdapter.java:639)
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Re: Error while loading data to cache
Posted by Roman Guseinov <ro...@gromtech.ru>.
Hi,
The error is clear, you try to cast BinaryObject to Customer type. It can
happen if you use CacheJdbcPojoStoreFactory for example. In this case, you
can use BinaryObject.field:
int id = ((BinaryObject)value).field("id");
return id == 1000000001;
According to your filter, cachestore will fetch all data from 3rd party
store and put into cache only entries with id == 1000000001. Is it what you
need?
Best Regards,
Roman
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Re: Error while loading data to cache
Posted by Skollur <Sk...@idbny.com>.
Your suggestion is working.Thank you.
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Re: Error while loading data to cache
Posted by Ilya Kasnacheev <il...@gmail.com>.
Hello!
Alternatively, you can set `storeKeepBinary' cache configuration setting to
false.
Regards,
--
Ilya Kasnacheev
пн, 17 сент. 2018 г. в 19:59, Skollur <Sk...@idbny.com>:
> I am trying to load data to cache using below code and seeing an error.
>
>
> ignite.cache("CustomerCache").loadCache(new IgniteBiPredicate()
> {
> @Override
> public boolean apply(Object key, Object
> value) {
> if(((Customer) value).getId()==1000000001);
> return true;
> }
> });
>
> ERROR:-
>
> Caused by: java.lang.ClassCastException:
> org.apache.ignite.internal.binary.BinaryObjectImpl cannot be cast to
> com.idb.cache.model.Customer
> at
> com.idb.cache.load.LoadIdbIgniteCaches$1.apply(LoadIdbIgniteCaches.java:36)
> at
>
> org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheAdapter.loadEntry(GridDhtCacheAdapter.java:639)
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>