java - 如何参考尚未持久化子对象的子对象(Objectify)首先保存父实体?
问题描述
有没有办法在方法中创建子实体的引用,但在不同的方法中保留子实体?
现在,我首先创建引用,然后以相同的方法保留子项。只有在完成此操作后,父级才会被持久化。如果在保存父实体期间发生 DatastoreTimeoutException、ConcurrentModificationException 或 DatastoreFailureException,我会留下子实体持久保存在数据存储区中,这是没有用的。
@Entity
@Index
public class parentEntity
{
@Id
private String uniqueIdentifier;
private String name = new String();
@Load
private LinkedList <Ref <childEntity>> refToChild = new LinkedList <Ref <childEntity>>();
}
@Entity
@Index
public class childEntity
{
@Id
private String uniqueIdentifier;
private String address = new String();
@Load
@Parent
public Ref <parentEntity> refToParent;
}
This method first creates the reference parent has with child and then persists the entity(child)
public static void createRefAndSaveChildEntity()
{
Ref.create( key ) ;//creates the reference with child
ofy().save().entity( childEntity ).now();
}
我只想在父母(参考孩子)被坚持之后才坚持孩子。
解决方案
推荐阅读
- python - Python MySQL 多函数显示 InternalError: Unread result found
- java - Dagger 2 问题:没有参数的@Subcomponent.Builder 方法必须返回@Subcomponent 类型
- panel - 使用 stata 中的面板数据创建年率变量的语法
- python - Pandas Spearman 相关性的问题
- go - 如何衡量 gRPC 响应的大小
- database - 如何使用 JDeveloper 12c REST 适配器将数据从数据库发布到 REST?
- jenkins - dsl中的jenkins naginator插件
- ada - 相当于 Ada 中的访问器
- c# - 无法在 MAC OS 上安装 ML.NET(项目不支持 DotnetTool)
- javascript - Firebase 存储 getDownloadUrl 不是函数