You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by Edward Chen <ja...@gmail.com> on 2020/02/11 21:59:45 UTC
sql insert, but key is null
Hello,
I am using Ignite 2.7.6 and testing its SQL insert function. I have
these codes:
PersonKey {
id: Long;
type: String;
// constructor, getter, setter ....
// hashCode, toString ...
}
Person {
id: Long;
type: String;
name: String;
zip: String;
public PersonKey getKey() {return new PersonKey(...);}
// constructor, getter, setter ....
// hashCode, toString ...
}
insert sql: "insert into Person(id, type, name, zip) values (100, "S",
"John", "11223")
when get data back from Cache,
Iterator<..> iter = cache.iterator();
while(iter.hasNext()){
Cache.Entry<PersonKey, Person> entry = iter.next();
entry.getKey --> *0,null *
}
The last output is not correct, it should be *"100, S"* .
Any inputs please ?
Thanks
Re: sql insert, but key is null
Posted by Evgenii Zhuravlev <e....@gmail.com>.
Yes, you're right.
вт, 11 февр. 2020 г. в 17:03, Edward Chen <ja...@gmail.com>:
> No, PersonKey doesn't have any annotation.
>
> Do you mean , I need add @QuerySqlField to PersonKey and remove those
> fields from Person class ?
>
>
> On 2/11/2020 7:23 PM, Evgenii Zhuravlev wrote:
>
> You have another class - PersonKey - do you have annotations there?
>
> Ignite has a key-value storage, so, Person object shouldn't have these key
> fields.
>
> вт, 11 февр. 2020 г. в 16:14, Edward Chen <ja...@gmail.com>:
>
>> Yes, all of them defined in Person
>>
>>
>> On 2/11/2020 6:29 PM, Evgenii Zhuravlev wrote:
>>
>> Did you add it to all fields in both key and value?
>>
>> Evgenii
>>
>> вт, 11 февр. 2020 г. в 15:18, Edward Chen <ja...@gmail.com>:
>>
>>> I just add @QuerySqlField to java field.
>>>
>>> Does Ignite have annotation for Primary Key ?
>>>
>>>
>>> Evgenii
>>>
>>> вт, 11 февр. 2020 г. в 13:59, Edward Chen <ja...@gmail.com>:
>>>
>>>> Hello,
>>>>
>>>> I am using Ignite 2.7.6 and testing its SQL insert function. I have
>>>> these codes:
>>>>
>>>>
>>>> PersonKey {
>>>> id: Long;
>>>> type: String;
>>>> // constructor, getter, setter ....
>>>> // hashCode, toString ...
>>>> }
>>>>
>>>> Person {
>>>> id: Long;
>>>> type: String;
>>>> name: String;
>>>> zip: String;
>>>>
>>>> public PersonKey getKey() {return new PersonKey(...);}
>>>>
>>>> // constructor, getter, setter ....
>>>> // hashCode, toString ...
>>>> }
>>>>
>>>> insert sql: "insert into Person(id, type, name, zip) values (100, "S",
>>>> "John", "11223")
>>>>
>>>> when get data back from Cache,
>>>> Iterator<..> iter = cache.iterator();
>>>> while(iter.hasNext()){
>>>> Cache.Entry<PersonKey, Person> entry = iter.next();
>>>>
>>>> entry.getKey --> *0,null *
>>>> }
>>>>
>>>> The last output is not correct, it should be *"100, S"* .
>>>>
>>>> Any inputs please ?
>>>>
>>>> Thanks
>>>>
>>>
>>
>
Re: sql insert, but key is null
Posted by Evgenii Zhuravlev <e....@gmail.com>.
You have another class - PersonKey - do you have annotations there?
Ignite has a key-value storage, so, Person object shouldn't have these key
fields.
вт, 11 февр. 2020 г. в 16:14, Edward Chen <ja...@gmail.com>:
> Yes, all of them defined in Person
>
>
> On 2/11/2020 6:29 PM, Evgenii Zhuravlev wrote:
>
> Did you add it to all fields in both key and value?
>
> Evgenii
>
> вт, 11 февр. 2020 г. в 15:18, Edward Chen <ja...@gmail.com>:
>
>> I just add @QuerySqlField to java field.
>>
>> Does Ignite have annotation for Primary Key ?
>>
>>
>> Evgenii
>>
>> вт, 11 февр. 2020 г. в 13:59, Edward Chen <ja...@gmail.com>:
>>
>>> Hello,
>>>
>>> I am using Ignite 2.7.6 and testing its SQL insert function. I have
>>> these codes:
>>>
>>>
>>> PersonKey {
>>> id: Long;
>>> type: String;
>>> // constructor, getter, setter ....
>>> // hashCode, toString ...
>>> }
>>>
>>> Person {
>>> id: Long;
>>> type: String;
>>> name: String;
>>> zip: String;
>>>
>>> public PersonKey getKey() {return new PersonKey(...);}
>>>
>>> // constructor, getter, setter ....
>>> // hashCode, toString ...
>>> }
>>>
>>> insert sql: "insert into Person(id, type, name, zip) values (100, "S",
>>> "John", "11223")
>>>
>>> when get data back from Cache,
>>> Iterator<..> iter = cache.iterator();
>>> while(iter.hasNext()){
>>> Cache.Entry<PersonKey, Person> entry = iter.next();
>>>
>>> entry.getKey --> *0,null *
>>> }
>>>
>>> The last output is not correct, it should be *"100, S"* .
>>>
>>> Any inputs please ?
>>>
>>> Thanks
>>>
>>
>
Re: sql insert, but key is null
Posted by Edward Chen <ja...@gmail.com>.
Yes, all of them defined in Person
On 2/11/2020 6:29 PM, Evgenii Zhuravlev wrote:
> Did you add it to all fields in both key and value?
>
> Evgenii
>
> вт, 11 февр. 2020 г. в 15:18, Edward Chen <java148@gmail.com
> <ma...@gmail.com>>:
>
> I just add @QuerySqlField to java field.
>
> Does Ignite have annotation for Primary Key ?
>
>>
>> Evgenii
>>
>> вт, 11 февр. 2020 г. в 13:59, Edward Chen <java148@gmail.com
>> <ma...@gmail.com>>:
>>
>> Hello,
>>
>> I am using Ignite 2.7.6 and testing its SQL insert function.
>> I have these codes:
>>
>>
>> PersonKey {
>> id: Long;
>> type: String;
>> // constructor, getter, setter ....
>> // hashCode, toString ...
>> }
>>
>> Person {
>> id: Long;
>> type: String;
>> name: String;
>> zip: String;
>>
>> public PersonKey getKey() {return new PersonKey(...);}
>>
>> // constructor, getter, setter ....
>> // hashCode, toString ...
>> }
>>
>> insert sql: "insert into Person(id, type, name, zip) values
>> (100, "S", "John", "11223")
>>
>> when get data back from Cache,
>> Iterator<..> iter = cache.iterator();
>> while(iter.hasNext()){
>> Cache.Entry<PersonKey, Person> entry = iter.next();
>>
>> entry.getKey --> *0,null *
>> }
>>
>> The last output is not correct, it should be *"100, S"* .
>>
>> Any inputs please ?
>>
>> Thanks
>>
Re: sql insert, but key is null
Posted by Evgenii Zhuravlev <e....@gmail.com>.
Did you add it to all fields in both key and value?
Evgenii
вт, 11 февр. 2020 г. в 15:18, Edward Chen <ja...@gmail.com>:
> I just add @QuerySqlField to java field.
>
> Does Ignite have annotation for Primary Key ?
>
>
> Evgenii
>
> вт, 11 февр. 2020 г. в 13:59, Edward Chen <ja...@gmail.com>:
>
>> Hello,
>>
>> I am using Ignite 2.7.6 and testing its SQL insert function. I have these
>> codes:
>>
>>
>> PersonKey {
>> id: Long;
>> type: String;
>> // constructor, getter, setter ....
>> // hashCode, toString ...
>> }
>>
>> Person {
>> id: Long;
>> type: String;
>> name: String;
>> zip: String;
>>
>> public PersonKey getKey() {return new PersonKey(...);}
>>
>> // constructor, getter, setter ....
>> // hashCode, toString ...
>> }
>>
>> insert sql: "insert into Person(id, type, name, zip) values (100, "S",
>> "John", "11223")
>>
>> when get data back from Cache,
>> Iterator<..> iter = cache.iterator();
>> while(iter.hasNext()){
>> Cache.Entry<PersonKey, Person> entry = iter.next();
>>
>> entry.getKey --> *0,null *
>> }
>>
>> The last output is not correct, it should be *"100, S"* .
>>
>> Any inputs please ?
>>
>> Thanks
>>
>
Re: sql insert, but key is null
Posted by Evgenii Zhuravlev <e....@gmail.com>.
Hi,
How did you create a mapping for SQL? The problem is that in key and value
classes you have fields with a same names - id & type. These fields are not
related to each other, I would recommend removing them from the Value class.
Evgenii
вт, 11 февр. 2020 г. в 13:59, Edward Chen <ja...@gmail.com>:
> Hello,
>
> I am using Ignite 2.7.6 and testing its SQL insert function. I have these
> codes:
>
>
> PersonKey {
> id: Long;
> type: String;
> // constructor, getter, setter ....
> // hashCode, toString ...
> }
>
> Person {
> id: Long;
> type: String;
> name: String;
> zip: String;
>
> public PersonKey getKey() {return new PersonKey(...);}
>
> // constructor, getter, setter ....
> // hashCode, toString ...
> }
>
> insert sql: "insert into Person(id, type, name, zip) values (100, "S",
> "John", "11223")
>
> when get data back from Cache,
> Iterator<..> iter = cache.iterator();
> while(iter.hasNext()){
> Cache.Entry<PersonKey, Person> entry = iter.next();
>
> entry.getKey --> *0,null *
> }
>
> The last output is not correct, it should be *"100, S"* .
>
> Any inputs please ?
>
> Thanks
>