{"action":"created","issue":{"url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-java/issues/1339","repository_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-java","labels_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-java/issues/1339/labels{/name}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-java/issues/1339/comments","events_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-java/issues/1339/events","html_url":"https://github.com/GoogleCloudPlatform/google-cloud-java/issues/1339","id":185547453,"number":1339,"title":"JavaDoc not clear as it could be, e.g. Datastore.add vs. Datastore.put","user":{"login":"unitydynamics","id":14965930,"avatar_url":"https://avatars.githubusercontent.com/u/14965930?v=3","gravatar_id":"","url":"https://api.github.com/users/unitydynamics","html_url":"https://github.com/unitydynamics","followers_url":"https://api.github.com/users/unitydynamics/followers","following_url":"https://api.github.com/users/unitydynamics/following{/other_user}","gists_url":"https://api.github.com/users/unitydynamics/gists{/gist_id}","starred_url":"https://api.github.com/users/unitydynamics/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/unitydynamics/subscriptions","organizations_url":"https://api.github.com/users/unitydynamics/orgs","repos_url":"https://api.github.com/users/unitydynamics/repos","events_url":"https://api.github.com/users/unitydynamics/events{/privacy}","received_events_url":"https://api.github.com/users/unitydynamics/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-java/labels/datastore","name":"datastore","color":"207de5"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2016-10-27T00:49:58Z","updated_at":"2016-10-27T17:46:51Z","closed_at":null,"body":"What's the difference between Datastore.add and Datastore.put?\r\n\r\nAm I right in assuming that \"add\" will **not** clobber existing entities?  \r\n\r\nMaybe a quick update to the javadoc to clarify--would be much appreciated!!!"},"comment":{"url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-java/issues/comments/256718812","html_url":"https://github.com/GoogleCloudPlatform/google-cloud-java/issues/1339#issuecomment-256718812","issue_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-java/issues/1339","id":256718812,"user":{"login":"mziccard","id":450933,"avatar_url":"https://avatars.githubusercontent.com/u/450933?v=3","gravatar_id":"","url":"https://api.github.com/users/mziccard","html_url":"https://github.com/mziccard","followers_url":"https://api.github.com/users/mziccard/followers","following_url":"https://api.github.com/users/mziccard/following{/other_user}","gists_url":"https://api.github.com/users/mziccard/gists{/gist_id}","starred_url":"https://api.github.com/users/mziccard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mziccard/subscriptions","organizations_url":"https://api.github.com/users/mziccard/orgs","repos_url":"https://api.github.com/users/mziccard/repos","events_url":"https://api.github.com/users/mziccard/events{/privacy}","received_events_url":"https://api.github.com/users/mziccard/received_events","type":"User","site_admin":false},"created_at":"2016-10-27T17:46:51Z","updated_at":"2016-10-27T17:46:51Z","body":"@unitydynamics Here are some more details:\r\n\r\n1. `add(Entity entity)`\r\n  - if `entity.key()` does not exist `entity` is inserted\r\n  - if `entity.key()` already exists the method throws a `DatastoreException ex` such that `ex.reason() == \"ALREADY_EXISTS\"` and the entity is not inserted\r\n\r\n2. `add(Entity... entities)` - this is syntactic on top of a batch operation (i.e. is not transactional)\r\n  - if none of entities' keys exist, all `entities` are inserted\r\n  - if any of `entities`' keys already exists the method throws a `DatastoreException ex` such that `ex.reason() == \"ALREADY_EXISTS\"`. All entities in `entities` whose key did not exist are inserted.\r\n\r\nYou might find strange that `add(Entity... entities)` throws an exception while still inserting non-existing entities. You might also be wondering which entities have been inserted, and which already existed. Unfortunately, the service does not provide us with that information (it just returns an `ALREADY_EXISTS` error) so there's nothing more that we can do with the information we have.\r\n\r\nBTW, you are totally right when saying that this must be added to our javadoc. Please keep this issue open until I add more docs."}}
{"actor":{"display_login":"mziccard"}}