1) Versant數據庫能夠直接支持複雜的業務模型:node public class Person {數據庫 String firstName;session String lastName;數據結構 String gender;dom String ethnicity;分佈式 String language;this // 新增的節點spa int index = 5;.net Contact info;對象 Location location; public String primaryCountry; public String primaryAreaCode; HashSet<Person> friends = new HashSet<Person>(); HashSet<Person> colleagues = new HashSet<Person>(); HashSet<Person> family = new HashSet<Person>(); HashSet<Person> relations = new HashSet<Person>(); } Versant數據庫能夠直接支持包括HashSet、LinkedList在內的複雜數據結構。 2)Versant數據庫能夠直接支持複雜的對象間的關係 以下的代碼中展現了一個兩層的關係結構。 public void addFriend( Person p ){ friends.add(p); addRelation(p); p.getFriends().add(this); } 3)Versant數據庫能夠很容易的創建和數據庫之間的鏈接: Iterator<DatabaseLoginHelper> ite = this.dblist.iterator(); DatabaseLoginHelper helper = (DatabaseLoginHelper)ite.next(); session = new TransSession(helper.getDatabaseNodeProperty()); session.setSchemaOption(TransSession.SCHEMA_ADD_DROP_ATTRIBUTES); // System.out.println("Define Logical database:"); session.newLogicalDatabase(HPC_DEMO_NETWORK_NAME); // System.out.println("Add to logical database:"+dbList[0]); session.addToLogicalDatabase(HPC_DEMO_NETWORK_NAME, helper.databaseName); System.out.println("Add to logical database:" + helper.databaseName); 4)Versant數據庫能夠很容易地建立對象,並保存到數據庫中。 TransSession session = DistributedDatabaseManager.getInstance() .createNewSession(); session.setDefaultDatabase("dbnodeb"); // TransSession session = new TransSession("dbnodea"); /** * generate 500 random objects */ for (int i = 0; i < 1500; i++) { Person person = new Person(); person.setFirstName("TFistName" + i); person.setLastName("TListName" + i); // set storage schema DistributedDatabaseManager.getInstance() .setRoundRobinPersistentSchema(); session.makePersistent(person); session.commit(); } System.out.println("Demo data generated."); session.commit(); 上面的例子中,能夠實現自動將數據對象配載到分佈式數據庫的不一樣節點中。 |