公开SNS社区即时找朋友链的源代码和部署方案(续四)

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();

猜你喜欢

转载自markhe.iteye.com/blog/1495425