can't get or query but scan works

classic Classic list List threaded Threaded
3 messages Options
relax ken relax ken
Reply | Threaded
Open this post in threaded view
|

can't get or query but scan works

Hi,

I am trying to use ignite query and indexing by following ignite example but can't get it work.

Here is my entity class:

public class UserIgniteRecord {
@QuerySqlField(index = true)
public final String userId;

@QuerySqlField(index = true)
public final String username;

@QuerySqlField(index = true)
public final String email;

public String getUserId() {
return userId;
}

public String getUsername() {
return username;
}

public String getEmail() {
return email;
}

public String getDeviceUniqueIdentifier() {
return deviceUniqueIdentifier;
}

public UserIgniteRecord(String userId, String username, String email) {
this.userId = userId;
this.username = username;
this.email = email;
}

@Override
public String toString(){
return userId +", "+ username + ", " + email;
}
}
I tried both `cconfig.setIndexedTypes(String.class, UserIgniteRecord.class);` and queryEntity 
When I scan, I get all records `[IgniteBiTuple [val1=250c187c-550a-44b3-bb33-79f1caa0f318, val2=250c187c-550a-44b3-bb33-79f1caa0f318, meme2, ], IgniteBiTuple [val1=1fdec81a-7b5a-444c-b184-675effee4177, val2=1fdec81a-7b5a-444c-b184-675effee4177, meme3, ], IgniteBiTuple [val1=1883e05c-64a4-499a-96fa-ea91b807a301, val2=1883e05c-64a4-499a-96fa-ea91b807a301, meme, ], IgniteBiTuple [val1=87b407ee-77c0-4d59-b53e-5c83af22cb7f, val2=87b407ee-77c0-4d59-b53e-5c83af22cb7f, meme2, ]]`
But when I use `userDBRecordCache.get(userId)`, cache returned nothing and also tried to load from persistence.
The same empty result for query `userDBRecordCache.query(new SqlFieldsQuery("select userId from " + UserIgniteRecord.class.getSimpleName() + " where username = ?"));`
Any ideas?

Thanks


relax ken relax ken
Reply | Threaded
Open this post in threaded view
|

Re: can't get or query but scan works

to correct the query, I did set args

`userDBRecordCache.query(new SqlFieldsQuery("select userId from " + UserIgniteRecord.class.getSimpleName() + " where username = ?").setArgs(userName));`

copied a wrong one in my last email

On Thu, Aug 8, 2019 at 4:09 PM relax ken <[hidden email]> wrote:
Hi,

I am trying to use ignite query and indexing by following ignite example but can't get it work.

Here is my entity class:

public class UserIgniteRecord {
@QuerySqlField(index = true)
public final String userId;

@QuerySqlField(index = true)
public final String username;

@QuerySqlField(index = true)
public final String email;

public String getUserId() {
return userId;
}

public String getUsername() {
return username;
}

public String getEmail() {
return email;
}

public String getDeviceUniqueIdentifier() {
return deviceUniqueIdentifier;
}

public UserIgniteRecord(String userId, String username, String email) {
this.userId = userId;
this.username = username;
this.email = email;
}

@Override
public String toString(){
return userId +", "+ username + ", " + email;
}
}
I tried both `cconfig.setIndexedTypes(String.class, UserIgniteRecord.class);` and queryEntity 
When I scan, I get all records `[IgniteBiTuple [val1=250c187c-550a-44b3-bb33-79f1caa0f318, val2=250c187c-550a-44b3-bb33-79f1caa0f318, meme2, ], IgniteBiTuple [val1=1fdec81a-7b5a-444c-b184-675effee4177, val2=1fdec81a-7b5a-444c-b184-675effee4177, meme3, ], IgniteBiTuple [val1=1883e05c-64a4-499a-96fa-ea91b807a301, val2=1883e05c-64a4-499a-96fa-ea91b807a301, meme, ], IgniteBiTuple [val1=87b407ee-77c0-4d59-b53e-5c83af22cb7f, val2=87b407ee-77c0-4d59-b53e-5c83af22cb7f, meme2, ]]`
But when I use `userDBRecordCache.get(userId)`, cache returned nothing and also tried to load from persistence.
The same empty result for query `userDBRecordCache.query(new SqlFieldsQuery("select userId from " + UserIgniteRecord.class.getSimpleName() + " where username = ?"));`
Any ideas?

Thanks


relax ken relax ken
Reply | Threaded
Open this post in threaded view
|

Re: can't get or query but scan works

sorry, nvm, it was a wrong setup. both work now. sorry for the spawn

On Thu, Aug 8, 2019 at 4:12 PM relax ken <[hidden email]> wrote:
to correct the query, I did set args

`userDBRecordCache.query(new SqlFieldsQuery("select userId from " + UserIgniteRecord.class.getSimpleName() + " where username = ?").setArgs(userName));`

copied a wrong one in my last email

On Thu, Aug 8, 2019 at 4:09 PM relax ken <[hidden email]> wrote:
Hi,

I am trying to use ignite query and indexing by following ignite example but can't get it work.

Here is my entity class:

public class UserIgniteRecord {
@QuerySqlField(index = true)
public final String userId;

@QuerySqlField(index = true)
public final String username;

@QuerySqlField(index = true)
public final String email;

public String getUserId() {
return userId;
}

public String getUsername() {
return username;
}

public String getEmail() {
return email;
}

public String getDeviceUniqueIdentifier() {
return deviceUniqueIdentifier;
}

public UserIgniteRecord(String userId, String username, String email) {
this.userId = userId;
this.username = username;
this.email = email;
}

@Override
public String toString(){
return userId +", "+ username + ", " + email;
}
}
I tried both `cconfig.setIndexedTypes(String.class, UserIgniteRecord.class);` and queryEntity 
When I scan, I get all records `[IgniteBiTuple [val1=250c187c-550a-44b3-bb33-79f1caa0f318, val2=250c187c-550a-44b3-bb33-79f1caa0f318, meme2, ], IgniteBiTuple [val1=1fdec81a-7b5a-444c-b184-675effee4177, val2=1fdec81a-7b5a-444c-b184-675effee4177, meme3, ], IgniteBiTuple [val1=1883e05c-64a4-499a-96fa-ea91b807a301, val2=1883e05c-64a4-499a-96fa-ea91b807a301, meme, ], IgniteBiTuple [val1=87b407ee-77c0-4d59-b53e-5c83af22cb7f, val2=87b407ee-77c0-4d59-b53e-5c83af22cb7f, meme2, ]]`
But when I use `userDBRecordCache.get(userId)`, cache returned nothing and also tried to load from persistence.
The same empty result for query `userDBRecordCache.query(new SqlFieldsQuery("select userId from " + UserIgniteRecord.class.getSimpleName() + " where username = ?"));`
Any ideas?

Thanks