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


Java ODatabaseDocument.commit方法代码示例

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


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

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

示例2: createOClass

import com.orientechnologies.orient.core.db.document.ODatabaseDocument; //导入方法依赖的package包/类
private OClass createOClass(ODatabaseDocument db, String className, boolean complexTypes) {
    OClass oClass = db.getMetadata().getSchema().createClass(className);
    oClass.createProperty(STRING_FIELD, OType.STRING);
    oClass.createProperty(NUMBER_FIELD, OType.INTEGER);
    oClass.createProperty(DATE_FIELD, OType.DATE);
    oClass.createProperty(DATETIME_FIELD, OType.DATETIME);
    if (complexTypes) {
        oClass.createProperty(LINK_FIELD, OType.LINK);
        oClass.createProperty(LINK_LIST_FIELD, OType.LINKLIST);
        oClass.createProperty(LINK_SET_FIELD, OType.LINKSET);
        oClass.createProperty(LINK_MAP_FIELD, OType.LINKMAP);
        oClass.createProperty(EMBEDDED_FIELD, OType.EMBEDDED);
        oClass.createProperty(EMBEDDED_LIST_FIELD, OType.EMBEDDEDLIST);
        oClass.createProperty(EMBEDDED_SET_FIELD, OType.EMBEDDEDSET);
        oClass.createProperty(EMBEDDED_MAP_FIELD, OType.EMBEDDEDMAP);
        oClass.createProperty(EMBEDDED_LIST_STRING_FIELD, OType.EMBEDDEDLIST);
        oClass.createProperty(EMBEDDED_SET_STRING_FIELD, OType.EMBEDDEDSET);
    }
    initPropertiesMap(oClass.propertiesMap());
    db.commit();
    return oClass;
}
 
开发者ID:OrienteerBAP,项目名称:wicket-orientdb,代码行数:23,代码来源:WicketOrientDbFilterTesterScope.java

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

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

import com.orientechnologies.orient.core.db.document.ODatabaseDocument; //导入方法依赖的package包/类
@Override
protected void beforeUpdateFormComponentModels() {
	super.beforeUpdateFormComponentModels();
	ODatabaseDocument db = OrientDbWebSession.get().getDatabase();
	isTransactionActive = db.getTransaction().isActive();
	if(isTransactionActive) db.commit();
}
 
开发者ID:OrienteerBAP,项目名称:wicket-orientdb,代码行数:8,代码来源:TransactionlessForm.java

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

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

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

示例9: end

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

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

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