创建复杂的对象关联,在Versant数据库中也非常容易,可以直接理解为内存对象的操作。
public void createKnownPerson() {
TransSession session = DistributedDatabaseManager.getInstance()
.createNewSession();
session.setDefaultDatabase("dbnodeb");
Person personA = new Person();
personA.setFirstName("AAF1");
personA.setLastName("AAL1");
Person personB = new Person();
personB.setFirstName("BBF1");
personB.setLastName("BBL1");
personB.addFriend(personA);
Person personC = new Person();
personC.setFirstName("CCF1");
personC.setLastName("CCL1");
personC.addFriend(personB);
Person personD = new Person();
personD.setFirstName("DDF1");
personD.setLastName("DDL1");
personD.addFriend(personC);
session.makePersistent(personA, "dbnodea");
session.makePersistent(personB, "dbnodeb");
session.makePersistent(personC, "dbnodea");
session.makePersistent(personD, "dbnodeb");
System.out.println("Special Test Data created.");
session.commit();
}