How to set AncestorKey to Entity when writing to Datastore from Apache Beam in Java?
up vote
0
down vote
favorite
I'd like to store two kinds of entities linked by a composition.
A User have multiple Order but I don't know how to set the relationship such as explained in the doc for AppEngine.
Key.Builder keyBuilder = DatastoreHelper.makeKey(kind, new String(order.getOrderId()));
Entity.Builder entityBuilder = Entity.newBuilder();
entityBuilder.setKey(keyBuilder);
entityBuilder.putProperties("order_id", DatastoreHelper.makeValue(order.getOrderId()).build());
entityBuilder.putProperties("user_id", DatastoreHelper.makeValue(order.getUserId()).build());
return entityBuilder.build();
I'd like to use a function like setAncestor() or addAncestor() any hints ?
java google-cloud-datastore google-cloud-dataflow apache-beam
add a comment |
up vote
0
down vote
favorite
I'd like to store two kinds of entities linked by a composition.
A User have multiple Order but I don't know how to set the relationship such as explained in the doc for AppEngine.
Key.Builder keyBuilder = DatastoreHelper.makeKey(kind, new String(order.getOrderId()));
Entity.Builder entityBuilder = Entity.newBuilder();
entityBuilder.setKey(keyBuilder);
entityBuilder.putProperties("order_id", DatastoreHelper.makeValue(order.getOrderId()).build());
entityBuilder.putProperties("user_id", DatastoreHelper.makeValue(order.getUserId()).build());
return entityBuilder.build();
I'd like to use a function like setAncestor() or addAncestor() any hints ?
java google-cloud-datastore google-cloud-dataflow apache-beam
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I'd like to store two kinds of entities linked by a composition.
A User have multiple Order but I don't know how to set the relationship such as explained in the doc for AppEngine.
Key.Builder keyBuilder = DatastoreHelper.makeKey(kind, new String(order.getOrderId()));
Entity.Builder entityBuilder = Entity.newBuilder();
entityBuilder.setKey(keyBuilder);
entityBuilder.putProperties("order_id", DatastoreHelper.makeValue(order.getOrderId()).build());
entityBuilder.putProperties("user_id", DatastoreHelper.makeValue(order.getUserId()).build());
return entityBuilder.build();
I'd like to use a function like setAncestor() or addAncestor() any hints ?
java google-cloud-datastore google-cloud-dataflow apache-beam
I'd like to store two kinds of entities linked by a composition.
A User have multiple Order but I don't know how to set the relationship such as explained in the doc for AppEngine.
Key.Builder keyBuilder = DatastoreHelper.makeKey(kind, new String(order.getOrderId()));
Entity.Builder entityBuilder = Entity.newBuilder();
entityBuilder.setKey(keyBuilder);
entityBuilder.putProperties("order_id", DatastoreHelper.makeValue(order.getOrderId()).build());
entityBuilder.putProperties("user_id", DatastoreHelper.makeValue(order.getUserId()).build());
return entityBuilder.build();
I'd like to use a function like setAncestor() or addAncestor() any hints ?
java google-cloud-datastore google-cloud-dataflow apache-beam
java google-cloud-datastore google-cloud-dataflow apache-beam
asked Nov 8 at 11:07
vdolez
591822
591822
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
The ancestor relationship is on the key of the entity not the entity itself. So you can either pass the parent key to DatastoreHelper.makeKey
or use addAncestors
on the key builder like you referenced in the doc for App Engine
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
The ancestor relationship is on the key of the entity not the entity itself. So you can either pass the parent key to DatastoreHelper.makeKey
or use addAncestors
on the key builder like you referenced in the doc for App Engine
add a comment |
up vote
0
down vote
The ancestor relationship is on the key of the entity not the entity itself. So you can either pass the parent key to DatastoreHelper.makeKey
or use addAncestors
on the key builder like you referenced in the doc for App Engine
add a comment |
up vote
0
down vote
up vote
0
down vote
The ancestor relationship is on the key of the entity not the entity itself. So you can either pass the parent key to DatastoreHelper.makeKey
or use addAncestors
on the key builder like you referenced in the doc for App Engine
The ancestor relationship is on the key of the entity not the entity itself. So you can either pass the parent key to DatastoreHelper.makeKey
or use addAncestors
on the key builder like you referenced in the doc for App Engine
answered Nov 9 at 21:01
Jim Morrison
57115
57115
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53206500%2fhow-to-set-ancestorkey-to-entity-when-writing-to-datastore-from-apache-beam-in-j%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown