【问题标题】:How Many Write Operation will be counted if Insert operation is done on parent entity?如果对父实体执行插入操作,将计算多少个写入操作?
【发布时间】:2014-07-01 16:53:20
【问题描述】:

我正在使用云端点处理谷歌云数据存储。我使用 JPA 注释在部门和员工之间创建了拥有的一对多关系。实体是:

Department(Parent)
   String Id
   String Name
   List Employee(@OneToMany)

Employee(Child)
   Key key
   String firstName
   String lastName
   String Address
   Department dept(@ManyToOne)

插入操作的代码是:

    Departmentendpoint dptendpoint=null;
    Departmentendpoint.Builder builder1 = new Departmentendpoint.Builder(AndroidHttp. 
                          newCompatibleTransport(), new JacksonFactory(), null);
    dptendpoint = CloudEndpointUtils.updateBuilder(builder1).build();

    Department dpt = new Department();
    dpt.setId("Dept1");
    dpt.setName("Safety");

    List<Employee> m = new ArrayList<Employee>(); 

    Employee mgr= new Employee();
    mgr.setFirstName("Devwrat");
    mgr.setLastName("Lad");
    mgr.setParentId(dpt.getId());
    mgr.setAddress("Mumbai");
    m.add(mgr);

    Employee mgr2= new Employee();
    mgr2.setFirstName("Avinash");
    mgr2.setLastName("Patel");
    mgr2.setParentId(dpt.getId());
    mgr2.setAddress("Surat");
    m.add(mgr2);

    dpt.setManager(m);
    try{
        dptendpoint.insertDepartment(dpt).execute();
    }catch(IOException e) {
        e.printStackTrace();
    }

问题

如果我对父实体进行插入查询“dptendpoint.insertDepartment(dpt).execute()”,将执行多少个写入操作?

提前谢谢!!!!

【问题讨论】:

    标签: google-app-engine jpa google-cloud-datastore google-cloud-endpoints


    【解决方案1】:

    我已经向谷歌渠道合作伙伴提出了同样的问题并得到了以下答复。

    It will be like inserting into two entities.
    

    所以基本上“dptendpoint.insertDepartment(dpt).execute()”查询的总写操作将是:20 写操作。下面解释:

    For Department Entity:
         1 (for the entity itself) + 1 (for the EntitiesByKind index) + 2 * 3(for indexed property) + 1 * 0 (for composite index) = 8 write operation
    
    For Employee Entity
         1 (for the entity itself) + 1 (for the EntitiesByKind index) + 2 * 5(for indexed property) + 1 * 0 (for composite index) = 12 write operation
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-11-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-08-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多