-
Notifications
You must be signed in to change notification settings - Fork 693
Error when comparing Key #2609
Comments
@beunick in this case you should pass an entity instead of a Key. It will be converted to a key automatically. Let me know if that works for you. Thanks |
@dmitry-s Thanks for the note but no it is not working.
And I still have this error message: Any other idea ? Thanks |
@beunick the message looks strange because you don't have any parameters of type Could you provide sample code so I could try to replicate your issue? Thanks |
Sorry @dmitry-s sorry I copy and paste the wrong error message, that message was what I got before code change : When changing the code as suggested: Here is the message I still have: `
|
@beunick ok that makes sense. Datastore requires you to create indexes for inequality filters unless you only use one field (see https://cloud.google.com/datastore/docs/concepts/queries#inequality_filters_are_limited_to_at_most_one_property). It's very easy to create indexes, see https://cloud.google.com/datastore/docs/concepts/indexes for reference. Let me know if that works for you. Thanks |
Thanks @dmitry-s I did add the indexes, I now have no error, the query seems to be executing successfully but the problem is I have no value return. When I do this (Inferior) Even when I do this (Equal): I have a feeling that the compare with the id (Key) inside the @query() is not working at all... Unless I miss something. Any help will be much appreciated. Thank You!! |
@beunick I tested this approach and it works for me. I would recommend testing your GQL query in GCP Datastore console in the web ui to make sure the query works as you expect. You can use key literals in GQL using this syntax: So your query would look similar to this one:
|
Hi @dmitry-s I just tested this query below in GCP datastore console and the return value is empty.
All those query in the console return empty value. I really don't know why. |
Hi @dmitry-s any luck testing this using Key with UUID ? |
Hi @beunick, I just verified that it works with string keys.
I am not sure why your query is not working. Try removing the |
Hi @dmitry-s Inside my application now, when I replace "id" by "key" like this I have this error: I am wondering if in your test you can make it work successfully using UUID in the Key inside your @query in your code ? |
@beunick I've tested that today and have confirmed that it works with String ID as well as Long. The error indicates that there was an issue with retrieving id property from an entity. Just to clarify, are you using String field annotated with Could you share the source code for both your entity and the method from the repository? Thanks |
Thank you @dmitry-s for the note. Below you will see code for Entity, Repository, Service and the code I create to generate the Key. The code in Repository with ID in the query:
` The code in Repository with key in the query: `
` Product Entity: `
} In the service:
` By the way just to let you know, here is the method that I used to generate my Key every time I create a new entity before saving to the DB:
` |
Hi @beunick , I was unable to replicate the issue using the code you provided - everything worked as expected for me. Could you create a small application that I can run and get this error message? (perhaps on github) I am curious - could you explain what exactly you are trying to accomplish with the Btw, the queries you use could be expensive because they are going to fetch all rows. I would recommend using Also, which version of Thanks |
Hi @dmitry-s, sorry for the late reply and thanks for the note Here is what I have in my POM file: It is the latest version ? |
The latest version is |
Hi @beunick did you eventually figure this out? Are you still planning to share the sample application? |
Hi,
I have issue, I am trying to do NOT EQUAL on key and I separate it in two queries as you can see in the code below. But I keep having error about the " ID property was required but does not exist for the type".
Can you please let me know why that ?
`
@repository
public interface ProductRepository extends DatastoreRepository<Product, Key> {
@query("select * from product where id > @product_key and code = @product_code")
Product existsByCodeLow(@param("product_code")String code, @param("product_key")Key key);
}
`
Here is the error I got:
org.springframework.cloud.gcp.data.datastore.core.mapping.DatastoreDataException: An ID property was required but does not exist for the type: class com.google.cloud.datastore.Key
The text was updated successfully, but these errors were encountered: