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

classic Classic list List threaded Threaded
8 messages Options
Naveen Naveen
Reply | Threaded
Open this post in threaded view
|

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

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

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

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

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

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

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

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

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

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

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 at Nabble.com.
ilya.kasnacheev ilya.kasnacheev
Reply | Threaded
Open this post in threaded view
|

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

Hello!

Sounds correct to me.

Regards,
--
Ilya Kasnacheev


ср, 30 дек. 2020 г. в 14:23, Naveen <[hidden email]>:
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 at Nabble.com.
Naveen Naveen
Reply | Threaded
Open this post in threaded view
|

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

Thanks for the confirmation Ilya.




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