本文整理汇总了Java中com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.query方法的典型用法代码示例。如果您正苦于以下问题:Java ODatabaseDocumentTx.query方法的具体用法?Java ODatabaseDocumentTx.query怎么用?Java ODatabaseDocumentTx.query使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx
的用法示例。
在下文中一共展示了ODatabaseDocumentTx.query方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testOrientDBfinalize
import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx; //导入方法依赖的package包/类
@Test
public void testOrientDBfinalize() throws Exception {
Thread.sleep(2000);
ODatabaseDocumentTx db = new ODatabaseDocumentTx(DB_URL).open(DB_USERNAME, DB_PASSWORD);
List<ODocument> dbResult = db.query(new OSQLSynchQuery<ODocument>("SELECT FROM "+TEST_CLASS));
assertEquals((int)2, dbResult.size());
assertNotNull(dbResult.get(1).field(TEST_LINK_PROPERTY));
db.close();
server.shutdown();
}
示例2: fetchFromDb
import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx; //导入方法依赖的package包/类
protected void fetchFromDb(ODatabaseDocumentTx db) {
List<ODocument> docs = db.query(new OSQLSynchQuery<>(String.format(GET_COMMAND, hostGroup)));
if (docs.size() == 0 || docs.size() > 1) {
LOG.error("Illegal OrientDB configuration state - " + docs.size() + " number of records.");
}
if (docs.size() > 0) {
configs = new ConcurrentHashMap<>(docs.get(0).field("map"));
}
}
示例3: populateCaseInsensitiveNameFieldBatch
import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx; //导入方法依赖的package包/类
private boolean populateCaseInsensitiveNameFieldBatch(final ODatabaseDocumentTx db) {
log.trace("Processing batch of {} component records...", BATCH_SIZE);
db.begin();
List<ODocument> components = db.query(SELECT_COMPONENT_BATCH);
if (components.isEmpty()) {
return false;
}
for (ODocument component : components) {
String name = component.field(P_NAME, String.class);
component.field(P_CI_NAME, name.toLowerCase(Locale.ENGLISH));
component.save();
}
db.commit();
return true;
}
示例4: testPointTransactionRollBack
import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx; //导入方法依赖的package包/类
@Test
public void testPointTransactionRollBack() {
ODatabaseDocumentTx db = new ODatabaseDocumentTx("memory:txPoint");
try {
db.create();
OSchema schema = db.getMetadata().getSchema();
OClass v = schema.getClass("V");
OClass oClass = schema.createClass("City");
oClass.setSuperClass(v);
oClass.createProperty("location", OType.EMBEDDED, schema.getClass("OPoint"));
oClass.createProperty("name", OType.STRING);
db.command(new OCommandSQL("CREATE INDEX City.location ON City(location) SPATIAL ENGINE LUCENE")).execute();
OIndex idx = db.getMetadata().getIndexManager().getIndex("City.location");
ODocument rome = newCity("Rome", 12.5, 41.9);
ODocument london = newCity("London", -0.1275, 51.507222);
db.begin();
db.command(new OCommandSQL("insert into City set name = 'Test' , location = ST_GeomFromText('" + PWKT + "')")).execute();
db.save(rome);
db.save(london);
String query = "select * from City where location && 'LINESTRING(-160.06393432617188 21.996535232496047,-160.1099395751953 21.94304553343818,-160.169677734375 21.89399562866819,-160.21087646484375 21.844928843026818,-160.21018981933594 21.787556698550834)' ";
List<ODocument> docs = db.query(new OSQLSynchQuery<ODocument>(query));
Assert.assertEquals(1, docs.size());
Assert.assertEquals(3, idx.getSize());
db.rollback();
query = "select * from City where location && 'LINESTRING(-160.06393432617188 21.996535232496047,-160.1099395751953 21.94304553343818,-160.169677734375 21.89399562866819,-160.21087646484375 21.844928843026818,-160.21018981933594 21.787556698550834)' ";
docs = db.query(new OSQLSynchQuery<ODocument>(query));
Assert.assertEquals(0, docs.size());
Assert.assertEquals(0, idx.getSize());
} finally {
db.drop();
}
}
示例5: testPointTransactionUpdate
import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx; //导入方法依赖的package包/类
@Test
public void testPointTransactionUpdate() {
ODatabaseDocumentTx db = new ODatabaseDocumentTx("memory:txPoint");
try {
db.create();
OSchema schema = db.getMetadata().getSchema();
OClass v = schema.getClass("V");
OClass oClass = schema.createClass("City");
oClass.setSuperClass(v);
oClass.createProperty("location", OType.EMBEDDED, schema.getClass("OPoint"));
oClass.createProperty("name", OType.STRING);
db.command(new OCommandSQL("CREATE INDEX City.location ON City(location) SPATIAL ENGINE LUCENE")).execute();
OIndex idx = db.getMetadata().getIndexManager().getIndex("City.location");
ODocument rome = newCity("Rome", 12.5, 41.9);
db.begin();
db.save(rome);
db.commit();
String query = "select * from City where location && 'LINESTRING(-160.06393432617188 21.996535232496047,-160.1099395751953 21.94304553343818,-160.169677734375 21.89399562866819,-160.21087646484375 21.844928843026818,-160.21018981933594 21.787556698550834)' ";
List<ODocument> docs = db.query(new OSQLSynchQuery<ODocument>(query));
Assert.assertEquals(0, docs.size());
Assert.assertEquals(1, idx.getSize());
db.begin();
db.command(new OCommandSQL("update City set location = ST_GeomFromText('" + PWKT + "')")).execute();
query = "select * from City where location && 'LINESTRING(-160.06393432617188 21.996535232496047,-160.1099395751953 21.94304553343818,-160.169677734375 21.89399562866819,-160.21087646484375 21.844928843026818,-160.21018981933594 21.787556698550834)' ";
docs = db.query(new OSQLSynchQuery<ODocument>(query));
Assert.assertEquals(1, docs.size());
Assert.assertEquals(1, idx.getSize());
db.commit();
query = "select * from City where location && 'LINESTRING(-160.06393432617188 21.996535232496047,-160.1099395751953 21.94304553343818,-160.169677734375 21.89399562866819,-160.21087646484375 21.844928843026818,-160.21018981933594 21.787556698550834)' ";
docs = db.query(new OSQLSynchQuery<ODocument>(query));
Assert.assertEquals(1, docs.size());
Assert.assertEquals(1, idx.getSize());
} finally {
db.drop();
}
}
示例6: boundingBoxTest
import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx; //导入方法依赖的package包/类
@Test
public void boundingBoxTest() {
ODatabaseDocumentTx db = new ODatabaseDocumentTx("memory:test");
db.create();
try {
OClass point = db.getMetadata().getSchema().createClass("Point");
point.createProperty("latitude", OType.DOUBLE);
point.createProperty("longitude", OType.DOUBLE);
db.command(new OCommandSQL("CREATE INDEX Point.ll ON Point(latitude,longitude) SPATIAL ENGINE LUCENE")).execute();
ODocument document = new ODocument("Point");
document.field("latitude", 42.2814837);
document.field("longitude", -83.7605452);
db.save(document);
List<?> query = db
.query(new OSQLSynchQuery<ODocument>(
"SELECT FROM Point WHERE [latitude, longitude] WITHIN [[42.26531323615103,-83.71986351411135],[42.29239784478525,-83.7662120858887]]"));
Assert.assertEquals(query.size(), 1);
} finally {
db.drop();
}
}