Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to query java appengine datastore VIEWER for entity using a Long id

I'm trying to do something relatively straightforward and something I think I used to be able to do.

I'm trying to use the admin interface to query my datastore using a long id. The entity in question is defined as:

@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable = "true")
public class Notification
{   
    @PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Long notificationId = null;
}

In the datastore viewer in the appengine admin interface, I perform the following gql query:

SELECT * FROM Notification WHERE _key_ = KEY('Notification', 12345)
SELECT * FROM Notification WHERE id = KEY('Notification', 12345)
SELECT * FROM Notification WHERE notificationId = KEY('Notification', 12345)
SELECT * FROM Notification WHERE notificationId = 12345

None of these queries return any results nor do they produce any errors. I am sure the entity exists. OIne of these used to work I just can't remember which. Could this be due to the recent appengine update to 1.3.6?

like image 508
aloo Avatar asked Sep 11 '26 12:09

aloo


1 Answers

You need this:

SELECT * FROM Notification WHERE __key__ = KEY('Notification', 12345)

Note two underscores around key, not one.

like image 100
Nick Johnson Avatar answered Sep 13 '26 03:09

Nick Johnson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!