【发布时间】: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