Rename an existing entity

249 views
Skip to first unread message

b...@soliduslink.com

unread,
May 22, 2018, 5:55:04 PM5/22/18
to objectify-appengine
Hi,

Is there a recommended way to rename an existing entity in the datastore?

Thanks a lot!

Best,
Baojun

Jeff Schnitzer

unread,
May 22, 2018, 6:08:24 PM5/22/18
to objectify-appengine
What does that mean ‘rename an existing entity’?

If you mean change the id of an entity… you create a new one with the same data and delete the old.

Jeff

--
You received this message because you are subscribed to the Google Groups "objectify-appengine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to objectify-appengine+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Baojun Xu

unread,
May 22, 2018, 6:12:47 PM5/22/18
to objectify...@googlegroups.com
For example if I want change the name of all my Manager entities in the DS to Employee? How would I do it?

On Wed, May 23, 2018 at 12:08 AM, Jeff Schnitzer <je...@infohazard.org> wrote:
What does that mean ‘rename an existing entity’?

If you mean change the id of an entity… you create a new one with the same data and delete the old.

Jeff
On Tue, May 22, 2018 at 7:17 AM, <b...@soliduslink.com> wrote:
Hi,

Is there a recommended way to rename an existing entity in the datastore?

Thanks a lot!

Best,
Baojun

--
You received this message because you are subscribed to the Google Groups "objectify-appengine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to objectify-appengine+unsubscribe...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "objectify-appengine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to objectify-appengine+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Baojun Xu

SolidusLink AG
Rütistrasse 16
8952 Schlieren

Jeff Schnitzer

unread,
May 22, 2018, 6:18:32 PM5/22/18
to objectify-appengine
OH you want to change the *kind* of an entity?

That’s pretty painful. If you have a lot of data, my advice would be to rename your Java class from Manager to Employee and add @Entity(name=“Manager”). In other words, leave the data in the datastore as-is and map it to a more sanely named class.

Otherwise you have to create all new entities, delete all the old entities, and update any foreign key references.

There is no equivalent of ALTER TABLE in the datastore.

Jeff

On Tue, May 22, 2018 at 3:12 PM, Baojun Xu <b...@soliduslink.com> wrote:
For example if I want change the name of all my Manager entities in the DS to Employee? How would I do it?

On Wed, May 23, 2018 at 12:08 AM, Jeff Schnitzer <je...@infohazard.org> wrote:
What does that mean ‘rename an existing entity’?

If you mean change the id of an entity… you create a new one with the same data and delete the old.

Jeff

On Tue, May 22, 2018 at 7:17 AM, <b...@soliduslink.com> wrote:
Hi,

Is there a recommended way to rename an existing entity in the datastore?

Thanks a lot!

Best,
Baojun

--
You received this message because you are subscribed to the Google Groups "objectify-appengine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to objectify-appengine+unsubscribe...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "objectify-appengine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to objectify-appengine+unsubscribe...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Baojun Xu

unread,
May 22, 2018, 6:35:28 PM5/22/18
to objectify...@googlegroups.com
OK great! That confirms what I thought. I guess I will write a script to do the migration. Thanks.
Reply all
Reply to author
Forward
0 new messages