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


Java ODatabaseDocument.close方法代码示例

本文整理汇总了Java中com.orientechnologies.orient.core.db.document.ODatabaseDocument.close方法的典型用法代码示例。如果您正苦于以下问题:Java ODatabaseDocument.close方法的具体用法?Java ODatabaseDocument.close怎么用?Java ODatabaseDocument.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.orientechnologies.orient.core.db.document.ODatabaseDocument的用法示例。


在下文中一共展示了ODatabaseDocument.close方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: execute

import com.orientechnologies.orient.core.db.document.ODatabaseDocument; //导入方法依赖的package包/类
/**
 * @return result of execution
 */
public final V execute()
{
	ODatabaseDocument db = null;
	ODatabaseDocument oldDb = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined();
	if(oldDb!=null) ODatabaseRecordThreadLocal.INSTANCE.remove(); //Required to avoid stack of transactions
	try
	{
		db = getSettings().getDatabasePoolFactory().get(getDBUrl(), getUsername(), getPassword()).acquire();
		db.activateOnCurrentThread();
		return execute(db);
	} 
	finally
	{
		if(db!=null) db.close();
		if(oldDb!=null) ODatabaseRecordThreadLocal.INSTANCE.set((ODatabaseDocumentInternal)oldDb);
		else ODatabaseRecordThreadLocal.INSTANCE.remove();
	}
}
 
开发者ID:OrienteerBAP,项目名称:wicket-orientdb,代码行数:22,代码来源:DBClosure.java

示例2: onAfterInitialized

import com.orientechnologies.orient.core.db.document.ODatabaseDocument; //导入方法依赖的package包/类
@Override
public void onAfterInitialized(Application application) {
	OrientDbWebApplication app = (OrientDbWebApplication)application;
	ODatabaseDocument db = getDatabase(app);
	try
	{
		installData(app, db);
	}
	catch(Exception ex)
	{
		LOG.error("Data can't be installed", ex);
	}
	finally
	{
		db.close();
	}
}
 
开发者ID:OrienteerBAP,项目名称:wicket-orientdb,代码行数:18,代码来源:AbstractDataInstallator.java

示例3: testClassChange

import com.orientechnologies.orient.core.db.document.ODatabaseDocument; //导入方法依赖的package包/类
@Test
@Ignore
public void testClassChange()
{
	ODatabaseDocument db = wicket.getTester().getDatabase();
	OSchema schema = db.getMetadata().getSchema();
	OClass classA = schema.createClass("TestClassChangeA");
	OClass classB = schema.createClass("TestClassChangeB");
	ODocument doc = new ODocument(classA);
	doc.save();
	doc = doc.getIdentity().getRecord();
	doc.setClassName(classB.getName());
	assertEquals(classB.getName(), doc.getClassName());
	doc = doc.getIdentity().getRecord();
	assertEquals(classB.getName(), doc.getClassName());
	ORID id = doc.getIdentity();
	db.commit(true);
	db.close();
	db = wicket.getTester().getDatabase();
	doc = id.getRecord();
	assertEquals(classB.getName(), doc.getClassName());
}
 
开发者ID:OrienteerBAP,项目名称:wicket-orientdb,代码行数:23,代码来源:TestInAppOrientDBCompatibility.java

示例4: onDetach

import com.orientechnologies.orient.core.db.document.ODatabaseDocument; //导入方法依赖的package包/类
@Override
public void onDetach(RequestCycle cycle) {
	ODatabaseDocument db = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined();
	if(db!=null) {
		if(db.getTransaction().isActive()) db.commit(true);
		db.close();
		ODatabaseRecordThreadLocal.INSTANCE.remove();
	}
}
 
开发者ID:OrienteerBAP,项目名称:wicket-orientdb,代码行数:10,代码来源:TransactionRequestCycleListener.java

示例5: testOrientDbLifeCycle

import com.orientechnologies.orient.core.db.document.ODatabaseDocument; //导入方法依赖的package包/类
public void testOrientDbLifeCycle(String dbURL, boolean createDb, boolean dropDb) throws Exception
	{
		Orient.instance().startup();
		assertNotNull(ODatabaseRecordThreadLocal.INSTANCE);
		Orient.instance().removeShutdownHook();
		OServer server = OServerMain.create();
		server.startup(OrientDbTestWebApplication.class.getResource("db.config.xml").openStream());
		server.activate();
		if(createDb)
		{
			ODatabaseDocument dbToCreate = new ODatabaseDocumentTx(dbURL);
			if(!dbToCreate.exists()) dbToCreate.create();
			dbToCreate.close();
		}
		assertNotNull(ODatabaseRecordThreadLocal.INSTANCE);
		ODatabaseDocument db = new OPartitionedDatabasePoolFactory().get(dbURL, "admin", "admin").acquire();
		db.close();
		assertNotNull(ODatabaseRecordThreadLocal.INSTANCE);
		if(dropDb)
		{
			ODatabaseDocument dbToDrop = new ODatabaseDocumentTx(dbURL);
			dbToDrop.open("admin", "admin");
			dbToDrop.drop();
		}
		server.shutdown();
		Orient.instance().shutdown();
//		Thread.sleep(50);
	}
 
开发者ID:OrienteerBAP,项目名称:wicket-orientdb,代码行数:29,代码来源:TestStandaloneOrientDBCompatibility.java

示例6: 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

示例7: 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.close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。