本文整理汇总了Java中com.orientechnologies.orient.core.db.document.ODatabaseDocument.begin方法的典型用法代码示例。如果您正苦于以下问题:Java ODatabaseDocument.begin方法的具体用法?Java ODatabaseDocument.begin怎么用?Java ODatabaseDocument.begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.orientechnologies.orient.core.db.document.ODatabaseDocument
的用法示例。
在下文中一共展示了ODatabaseDocument.begin方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setObject
import com.orientechnologies.orient.core.db.document.ODatabaseDocument; //导入方法依赖的package包/类
@Override
public void setObject(V object) {
ODatabaseDocument db = OrientDbWebSession.get().getDatabase();
boolean isActiveTransaction = db.getTransaction().isActive();
if(isActiveTransaction) db.commit(); // Schema changes should be done outside of transaction
try {
setValue(objectModel.getObject(), parameterModel.getObject(), object);
} finally {
if(isActiveTransaction) db.begin();
}
}
示例2: testTransactions
import com.orientechnologies.orient.core.db.document.ODatabaseDocument; //导入方法依赖的package包/类
@Test
public void testTransactions() throws Exception {
ODatabaseDocument db = wicket.getTester().getDatabase();
try {
assertFalse(db.getTransaction().isActive());
OSchema schema = db.getMetadata().getSchema();
OClass classA = schema.createClass("TransA");
classA.createProperty("name", OType.STRING);
ODocument doc = new ODocument(classA);
doc.field("name", "test1");
doc.save();
ORID orid = doc.getIdentity();
db.begin();
assertTrue(db.getTransaction().isActive());
doc = orid.getRecord();
assertEquals("test1", doc.field("name"));
doc.field("name", "test2");
doc = orid.getRecord();
assertEquals("test2", doc.field("name"));
//There is NO SAVE!
db.commit();
db.getLocalCache().clear();
/* COMMENT START */
//db.close();
//db = wicket.getTester().getDatabase();
/* COMMENT STOP */
doc = orid.getRecord();
assertEquals("test1", doc.field("name"));
} finally {
db.commit();
}
}
示例3: testTransactions2
import com.orientechnologies.orient.core.db.document.ODatabaseDocument; //导入方法依赖的package包/类
@Test
@Ignore
public void testTransactions2() throws Exception {
ODatabaseDocument db = wicket.getTester().getDatabase();
try {
assertFalse(db.getTransaction().isActive());
OSchema schema = db.getMetadata().getSchema();
OClass classA = schema.createClass("TransB");
classA.createProperty("name", OType.STRING);
ODocument doc = new ODocument(classA);
doc.field("name", "test1");
doc.save();
ORID orid = doc.getIdentity();
db.begin();
assertTrue(db.getTransaction().isActive());
doc = orid.getRecord();
assertEquals("test1", doc.field("name"));
doc.field("name", "test2");
doc.save();
doc = orid.getRecord();
assertEquals("test2", doc.field("name"));
doc.field("name", "test3");
assertEquals("test3", doc.field("name"));
//There is NO SAVE!
db.commit();
db.getLocalCache().clear();
/* COMMENT START */
//db.close();
//db = wicket.getTester().getDatabase();
/* COMMENT STOP */
doc = orid.getRecord();
assertEquals("test2", doc.field("name"));
} finally {
db.commit();
}
}
示例4: testLoosingLinkedClass
import com.orientechnologies.orient.core.db.document.ODatabaseDocument; //导入方法依赖的package包/类
@Test
@Ignore
public void testLoosingLinkedClass() throws Exception
{
ODatabaseDocument db = wicket.getTester().getDatabase();
OSchema schema = wicket.getTester().getSchema();
OClass mainClass = schema.createClass("LMainClass");
OClass embeddedClass = schema.createClass("LEmbeddedClass");
mainClass.createProperty("name", OType.STRING);
mainClass.createProperty("embedded", OType.EMBEDDED).setLinkedClass(embeddedClass);
embeddedClass.createProperty("name", OType.STRING);
db.begin();
ODocument main = new ODocument(mainClass);
main.field("name", "main");
ODocument embedded = new ODocument(embeddedClass);
//embedded.field("name", "embedded");
main.field("embedded", embedded);
//NO Save here!
db.commit();
db.close();
main.fromStream(main.toStream());
db = wicket.getTester().getDatabase();
db.begin();
assertEmbeddedIsCorrect(main);
main.save();
ORID recordId = main.getIdentity();
db.commit();
db.close();
db = wicket.getTester().getDatabase();
db.begin();
main = recordId.getRecord();
assertEmbeddedIsCorrect(main);
db.commit();
}
示例5: interupt
import com.orientechnologies.orient.core.db.document.ODatabaseDocument; //导入方法依赖的package包/类
private void interupt(ODatabaseDocument db, IModel<?> model) {
model.detach();
db.commit();
db.getLocalCache().clear();
db.begin();
}
示例6: testOFunctions
import com.orientechnologies.orient.core.db.document.ODatabaseDocument; //导入方法依赖的package包/类
@Test
public void testOFunctions() throws Exception
{
ODatabaseDocument db = wicket.getTester().getDatabase();
ODocument doc = new ODocument(OFunction.CLASS_NAME);
doc.field("name", "testResurection");
doc.field("language", "JavaScript");
doc.field("idempotent", true);
doc.save();
ORID orid = doc.getIdentity();
for(int i=0;i<10;i++)
{
db = wicket.getTester().getDatabase();
String signature = "signature"+RANDOM.nextLong();
boolean isGoodCall = (i+1)%3 != 0;
db.begin();
doc = orid.getRecord();
String code = isGoodCall?"return \""+signature+"\";":"return nosuchvar;";
doc.field("code", code);
doc.save();
db.commit();
db.close();
if(isGoodCall)
{
String result;
for(int j=0; j<3;j++)
{
result = wicket.getTester().executeUrl("orientdb/function/db/testResurection", "GET", null);
assertContains(signature, result);
}
}
else
{
try
{
wicket.getTester().executeUrl("orientdb/function/db/testResurection", "GET", null);
assertFalse("We should be there, because function should have 400 response", true);
} catch (Exception e)
{
//NOP
}
}
}
}