google-cloud-datastore

how to apply date filter on ancestor query

橙三吉。 提交于 2019-12-04 05:49:16
问题 I have two entity model Student and attendance such that each attendance entity has associated student parent. Attendance model: @Entity public class Attendance { @Id Long id; @Index Date date; @Parent @Index @ApiResourceProperty(ignored = AnnotationBoolean.TRUE) Ref<Student> studentRef; public Long getId() { return id; } public Date getDate() { return date; } public void setDate(Date date) { this.date = date; } public String getWebsafeKey() { return Key.create(studentRef.getKey(), Attendance

Inconsistent Fetch From Google App Engine Datastore

回眸只為那壹抹淺笑 提交于 2019-12-04 05:48:11
I have an application deployed in Google app engine. I am getting inconsistent data when i fetch an entity by id immediately after updating that entity. I'm using JDO 3.0 to access the app engine datastore. I have an entity Employee @PersistenceCapable(detachable = "true") public class Employee implements Serializable { /** * */ private static final long serialVersionUID = -8319851654750418424L; @PrimaryKey @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY, defaultFetchGroup = "true") @Extension(vendorName = "datanucleus", key = "gae.encoded-pk", value = "true") private String id;

How to save an entity in GAE datastore only if it does not exist while preventing race conditions

﹥>﹥吖頭↗ 提交于 2019-12-04 05:42:53
问题 I am trying to save an entity to Google App Engine Datastore only if it does not exist, if it does the thread should not continue. Main issue is: I want to prevent any race conditions, such that if 2 threads are doing this at the same time only one would succeed in saving the entity. I am not sure what is the best approach for this, would using Transactions work or one must rely on other solutions such as using Memcache Please provide answer in low level API in java 回答1: Assuming that the

The 5 writes per second for an entity group

前提是你 提交于 2019-12-04 05:19:14
Suppose we have 5 entities: A,B,C,D,E with the following ancestor hierarchy: A / \ B C / \ D E I have two questions about this: Do we have 2 entity groups here (A,B,D) and (A,C,E) or just 1 entity group (A,B,C,D,E)? If we want to update entities D and E, can we update each of them 5 times per second or should the combined writes for D,E not exceed 5? Xion There is only one entity without a parent here - that is, A. It is therefore a root entity of the sole entity group that contains A, B, C, D and E. Entity group is simply a distinct tree of entities linked by parent-child relationship. As for

How do you implement cascading delete in Objectify?

允我心安 提交于 2019-12-04 05:13:46
I have the following heriacy. GrandParent --> Parent --> Child Parent and Child use @Parent Ref<GrandParent> and @Parent Ref<Parent> to create there parent relationship. I am trying to come of with a good way to do a cascading delete for GrandParent . I of course I could load all the children, generate keys from them and delete by key. This seems terribly inefficient. Is there something where I could query by parent and turn the query results into a list of keys without having to do the full fetch? Any thoughts, or third party libraries welcome. Basically, what Michael said, but here is the

ndb.BlobProperty vs BlobStore: which is more private and more secure

好久不见. 提交于 2019-12-04 04:27:22
I have been reading all over stackoverflow concerning datastore vs blobstore for storing and retrieving image files. Everything is pointing towards blobstore except one: privacy and security. In the datastore, the photos of my users are private: I have full control on who gets a blob. In the blobstore, however, anyone who knows the url can conceivable access my users photos? Is that true? Here is a quote that is supposed to give me peace of mind, but it's still not clear. So anyone with the blob key can still access the photos? (from Store Photos in Blobstore or as Blobs in Datastore - Which

Manage nested list of entities within entities in Google Cloud Datastore

一曲冷凌霜 提交于 2019-12-04 04:19:31
问题 I am new to Datastore and I am trying to create a simple app that tracks books borrowing. I would like the DB schema to be as follows: books: book_id name: borrowing: timestamp: user_id firstname email users: name: borrowed: timestamp: book_id I am using the console to configure the DB. I have defined two Kinds: Books and User Business logic: 1 book can be borrowed by n users. 1 user can borrow n books Basically, when a user borrows a book I want the two following inserts to occur: a new

Google App Engine - DELETE JPQL Query and Cascading

廉价感情. 提交于 2019-12-04 03:57:53
I noticed that the children of PersistentUser are not deleted when using the JPQL query below. However, the children are deleted if I perform an entityManager.remove(object) . Is this expected? Why doesn't the JPQL query below also perform a cascaded delete? @OneToMany(mappedBy = "persistentUser", cascade = CascadeType.ALL) private Collection<PersistentLogin> persistentLogins; ... @Override @Transactional public final void removeUserTokens(final String username) { final Query query = entityManager.createQuery( "DELETE FROM PersistentUser p WHERE username = :username"); query.setParameter(

Search a string beginning with a prefix in Google App Engine Datastore

橙三吉。 提交于 2019-12-04 03:52:57
问题 I want to search all entities whose name starts with a specific string, is this possible in Datastore? I've tried this: q = datastore.NewQuery("Places").Filter("Name > ", "a") But it doesn't work. If this is not possible, what alternative solution can you suggest to me? BigQuery? BigTable or other services on App Engine? 回答1: This is something that is possible, but with a combination of 2 inequality filters. Let's say you want to list Places that have the "li" prefix. This can be described

Complex Queries using GAE datastore

心不动则不痛 提交于 2019-12-04 03:29:34
I am in the early stages of developing a sports statistics website (ultimate frisbee) and would like to know your opinions if Google App Engine is right for me. I am writing it in Python using Django and have been comfortable with standard RDBMS for years but this site is a long term project and I am expecting very large amounts of data so I would like the "infinite" scaling that the GAE datastore offers. A vast majority of the queries to the database will return very standard results that would make the datastore seem like a logical choice. However, I would like to be able to make extremely