Ok I will try it... On Tue, 14 Jul 2020 at 22:34, Evgenii Zhuravlev <[email protected]> wrote:
> John, > > It's not necessary to have class at all, you can specify any type, you > just need to use this type when creating binary object for this key. > > вт, 14 июл. 2020 г. в 17:50, John Smith <[email protected]>: > >> I just used two columns as primary key... >> >> Of I use key_type and specify a type does that class need to exist in the >> class path of the server nodes? >> >> Like if I have >> >> class MyKeyClass { >> Integer col1; >> Integer col2; >> } >> >> Does this class need to be loaded in all nodes or ignite can figure it >> out and marshal it? >> >> On Tue., Jul. 14, 2020, 6:50 p.m. Evgenii Zhuravlev, < >> [email protected]> wrote: >> >>> Hi John, >>> >>> To do this, you need to create a key object with the same type as you >>> have for the table. If you don't specify KEY_TYPE in the create table >>> script, it will be generated automatically. I would recommend to specify it >>> for the command(just type name, if you don't have a class) and, when you >>> need to get data using key-value API, just create a binary object of this >>> type with these fields: >>> https://www.gridgain.com/docs/latest/developers-guide/key-value-api/binary-objects#creating-and-modifying-binary-objects >>> >>> Evgenii >>> >>> вт, 14 июл. 2020 г. в 07:18, John Smith <[email protected]>: >>> >>>> Hi, I have an SQL table >>>> >>>> create table if not exists my_table ( >>>> column1 int, >>>> column2 int, >>>> column3 varchar(16), >>>> PRIMARY KEY (column1, column2) >>>> ) with "template=replicatedTpl"; >>>> >>>> and I'm creating my near cache as follows... >>>> >>>> IgniteCache<Integer, String> myCache; >>>> >>>> NearCacheConfiguration<Integer, String> nearConfig = new >>>> NearCacheConfiguration<>(); >>>> nearConfig.setNearEvictionPolicyFactory(new >>>> LruEvictionPolicyFactory<>(1024)); >>>> >>>> myCache = >>>> this.ignite.getOrCreateNearCache(SQL_PUBLIC_MY_TABLE, nearConfig) >>>> .withExpiryPolicy(new AccessedExpiryPolicy(new Duration(TimeUnit.HOURS, >>>> 1))); >>>> >>>> So if I use myCache.get()... >>>> >>>> 1- How do I specify the primary key if it's 2 columns? >>>> 2- I assume the data will be put in near cache? >>>> >>>> >>>> >>>> >>>>
