According OrientDB official doc, I should create Connection Pool with Object API with following code.
// OPEN THE DATABASE
OObjectDatabaseTx db= OObjectDatabasePool.global().acquire("remote:localhost/petshop", "admin", "admin");
However, I found that OObjectDatabasePool class has been deprecated and suggested to use com.orientechnologies.orient.core.db.OPartitionedDatabasePool instead.
But in that way, how can I get OObjectDatabaseTx object? That is because OPartitionedDatabasePool.acquire() can only return ODatabaseDocumentTx object.
Hope there are someone knows how to resolve it.
Thanks
With this code you can get "object to connect to" and then make queries etc.
GET DOCUMENT DB
String remote = "remote:localhost/";
String nameDB = "domain";
String url = remote + nameDB;
OPartitionedDatabasePool pool = new OPartitionedDatabasePool(url, "admin", "admin");
ODatabaseDocumentTx db = pool.acquire();
//use example
List<ODocument> resultset = db.query(new OSQLSynchQuery<Object>("select from ORole"));
for(ODocument doc:resultset) {
System.out.println(doc);
}
db.close();
GET OBJECT DB
String remote = "remote:localhost/";
String nameDB = "TestPartitioned2";
String url = remote + nameDB;
OServerAdmin serverAdmin = new OServerAdmin(url).connect("root", "root");
serverAdmin.createDatabase(nameDB, "object", "plocal");
System.out.println(" Database '"+nameDB +"' created!..");
OPartitionedDatabasePool pool = new OPartitionedDatabasePool(url, "admin", "admin");
//object
OObjectDatabaseTx db = new OObjectDatabaseTx(pool.acquire());
db.getEntityManager().registerEntityClass(Person.class);
Person personA = db.newInstance(Person.class);
personA.setName("tennantA");
db.save(personA);
db.close();