You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by Naveen <na...@gmail.com> on 2020/12/29 06:56:39 UTC

Is Model class OR a value object mandatory for inserting the data thru non SQL API

HI

We dont need a model / pojo class or value object defined for a table while
creating a table and we can still insert data thru SQL and read the data
thru SQL API as well as Java KV or binary objects
However, if we want to insert data thru Java API by using binary object or
KV (put cache), we do need to a value object right ?? Even if use
BinaryObject also, we do need a POJO right for building the binary object ?
Is there a way, we can insert data without using a pojo class completely.
I do know that, if we dont define a value_type field while creating a table,
Ignite will give some random name to the the value_type to SQL_bla_bla etc..

Thanks
Naveen



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: Is Model class OR a value object mandatory for inserting the data thru non SQL API

Posted by Naveen <na...@gmail.com>.
Thanks for the confirmation Ilya.




--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: Is Model class OR a value object mandatory for inserting the data thru non SQL API

Posted by Ilya Kasnacheev <il...@gmail.com>.
Hello!

Sounds correct to me.

Regards,
-- 
Ilya Kasnacheev


ср, 30 дек. 2020 г. в 14:23, Naveen <na...@gmail.com>:

> On the same email chain what is the best way to create a cache, which
> should work for both KV, Binary and SQL CREATE TABLE IF NOT EXISTS
> curated.TEST_1_COPY ( test_id VARCHAR, test_f1 VARCHAR, created_On1
> timestamp, PRIMARY KEY (test_id)) WITH "TEMPLATE=TemplateWith1Copy,
> value_type=org.XXXX.ignite.model.Test1Copy, CACHE_NAME=TEST_1_COPY"; 1.
> Always good to mention the value type field while creation, but its up to
> you whether you use KV, Binary , SQL approach. SQL will work as it is, no
> issues For Binary, when we are building the Binary object, we should use
> the value type exactly what I mentioned above For using KV approach, we
> need to create a POJO with the the above class name. Is my understanding
> correct or any better ways of creating the cache which works for all APIs
> Thanks Naveen
> ------------------------------
> Sent from the Apache Ignite Users mailing list archive
> <http://apache-ignite-users.70518.x6.nabble.com/> at Nabble.com.
>

Re: Is Model class OR a value object mandatory for inserting the data thru non SQL API

Posted by Naveen <na...@gmail.com>.
On the same email chainwhat is the best way to create a cache, which should
work for both KV, Binary and SQLCREATE TABLE IF NOT EXISTS
curated.TEST_1_COPY (  test_id VARCHAR,   test_f1 VARCHAR,   created_On1
timestamp, PRIMARY KEY (test_id))  WITH "TEMPLATE=TemplateWith1Copy,
value_type=org.XXXX.ignite.model.Test1Copy, CACHE_NAME=TEST_1_COPY";1.
Always good to mention the value type field while creation, but its up to
you whether you use KV, Binary , SQL approach.          SQL will work as it
is, no issues         For Binary, when we are building the Binary object, we
should use the value type exactly what I          mentioned above        
For using KV approach, we need to create a POJO with the the above class
name.Is my understanding correct or any better ways of creating the cache
which works for all APIsThanksNaveen



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: Is Model class OR a value object mandatory for inserting the data thru non SQL API

Posted by Naveen <na...@gmail.com>.
I just created the cache by running the below SQL from SQLLine console

CREATE TABLE IF NOT EXISTS TEST_STATS_NAVEEN_NO_VAL (
  stats_id VARCHAR, testname VARCHAR, testcityId VARCHAR, PRIMARY KEY
(stats_id))
  WITH "template=myCacheTemplate,
DATA_REGION=persistwarm,CACHE_NAME=TEST_STATS_NAVEEN_NO_VAL";  

Since I have not given any value_type, Ignite has created a value for
value_type like this
"SQL_PUBLIC_TEST_STATS_NAVEEN_NO_VAL_532f9920_b7a2_43de_b6a2_2f45ad8d5c2a" 

So, when we are doing ignite.binary().builder(), we should exactly pass the
same value
SQL_PUBLIC_TEST_STATS_NAVEEN_NO_VAL_532f9920_b7a2_43de_b6a2_2f45ad8d5c2a, 
then only we should be able to retrieve the data inserted thru BinaryAPI
from SQL.
Thanks





--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: Is Model class OR a value object mandatory for inserting the data thru non SQL API

Posted by Pavel Tupitsyn <pt...@apache.org>.
How do you configure the cache?
QueryEntity.valueType should be the same string as you use in
ignite.binary().builder()

On Tue, Dec 29, 2020 at 11:08 AM Naveen <na...@gmail.com> wrote:

> This way if we insert
>
> gnite.binary().builder("ANY_STRING_HERE");
> builder.setField("id", 1);
> builder.setField("name", "John");
>
> We wont be able to retrieve the data thru SQL API. I did the same, but I
> dont see the records which I inserted thru Binary API by using the above.
>
> We get this error while inserting it
>
> [2020-12-29 12:04:47,862][WARN ][sys-stripe-7-#8][GridQueryProcessor]
> Key-value pair is not inserted into any SQL table
> [cacheName=TEST_STATS_NAVEEN_NO_VAL,
>
> expValType=SQL_PUBLIC_TEST_STATS_NAVEEN_NO_VAL_532f9920_b7a2_43de_b6a2_2f45ad8d5c2a,
> actualValType=TestStatsNaveen]
>
> It does expects the same value_type which Ignite has assigned when the
> table
> was created.
> However ScanQuery returns all the rows, guess it does the table scan.
>
> Am i missing something or its fair understanding on how this work
>
> Thanks
> Naveen
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>

Re: Is Model class OR a value object mandatory for inserting the data thru non SQL API

Posted by Naveen <na...@gmail.com>.
This way if we insert 

gnite.binary().builder("ANY_STRING_HERE");
builder.setField("id", 1);
builder.setField("name", "John");

We wont be able to retrieve the data thru SQL API. I did the same, but I
dont see the records which I inserted thru Binary API by using the above. 

We get this error while inserting it

[2020-12-29 12:04:47,862][WARN ][sys-stripe-7-#8][GridQueryProcessor]
Key-value pair is not inserted into any SQL table
[cacheName=TEST_STATS_NAVEEN_NO_VAL,
expValType=SQL_PUBLIC_TEST_STATS_NAVEEN_NO_VAL_532f9920_b7a2_43de_b6a2_2f45ad8d5c2a,
actualValType=TestStatsNaveen]

It does expects the same value_type which Ignite has assigned when the table
was created.
However ScanQuery returns all the rows, guess it does the table scan. 

Am i missing something or its fair understanding on how this work

Thanks
Naveen



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: Is Model class OR a value object mandatory for inserting the data thru non SQL API

Posted by Pavel Tupitsyn <pt...@apache.org>.
Hi, you can use BinaryObject API without defining any classes:

ignite.binary().builder("ANY_STRING_HERE");
builder.setField("id", 1);
builder.setField("name", "John");

On Tue, Dec 29, 2020 at 9:56 AM Naveen <na...@gmail.com> wrote:

> HI
>
> We dont need a model / pojo class or value object defined for a table while
> creating a table and we can still insert data thru SQL and read the data
> thru SQL API as well as Java KV or binary objects
> However, if we want to insert data thru Java API by using binary object or
> KV (put cache), we do need to a value object right ?? Even if use
> BinaryObject also, we do need a POJO right for building the binary object ?
> Is there a way, we can insert data without using a pojo class completely.
> I do know that, if we dont define a value_type field while creating a
> table,
> Ignite will give some random name to the the value_type to SQL_bla_bla
> etc..
>
> Thanks
> Naveen
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>