当前位置: 首页>>代码示例>>Java>>正文


Java ODatabaseDocument.begin方法代码示例

本文整理汇总了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();
	}
}
 
开发者ID:OrienteerBAP,项目名称:wicket-orientdb,代码行数:12,代码来源:AbstractCustomValueModel.java

示例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();
	}
}
 
开发者ID:OrienteerBAP,项目名称:wicket-orientdb,代码行数:34,代码来源:TestInAppOrientDBCompatibility.java

示例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();
	}
}
 
开发者ID:OrienteerBAP,项目名称:wicket-orientdb,代码行数:39,代码来源:TestInAppOrientDBCompatibility.java

示例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();
}
 
开发者ID:OrienteerBAP,项目名称:wicket-orientdb,代码行数:39,代码来源:TestInAppOrientDBCompatibility.java

示例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();
}
 
开发者ID:OrienteerBAP,项目名称:wicket-orientdb,代码行数:7,代码来源:TestModels.java

示例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
			}
		}
	}
}
 
开发者ID:OrienteerBAP,项目名称:wicket-orientdb,代码行数:45,代码来源:TestInAppOrientDBCompatibility.java


注:本文中的com.orientechnologies.orient.core.db.document.ODatabaseDocument.begin方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。