Open mmihira opened 1 year ago
Thanks for reporting this, I was able to reproduce this issue and it looks like to me that writing/updating an entity that's lazy referenced is not supported in the code base as of now. We'll look into this bug a bit more.
In the meantime, a less ideal temporary workaround is to do a copy of this retrievedChild
and saving this copy instead. Something similar to this for your sample code:
Child childToSave = Child.builder().id(retrievedChild.getId()).value("updated child").build();
childRepository.save(childToSave);
Thanks for looking into it.
Describe the bug
Given Parent references a Child via @LazyReference.
Retrieve the parent, then access the child. Make a modification to only the child and then attempt to save the child. An error results:
error on save here: com.google.cloud.spring.data.datastore.core.mapping.DatastoreDataException: Cloud Datastore can only allocate IDs for Long and Key properties. Cannot allocate for type: class java.lang.String
Sample https://github.com/mmihira/spring-datastore-reference-example
The test is below.