本文整理汇总了Java中com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.countClass方法的典型用法代码示例。如果您正苦于以下问题:Java ODatabaseDocumentTx.countClass方法的具体用法?Java ODatabaseDocumentTx.countClass怎么用?Java ODatabaseDocumentTx.countClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx
的用法示例。
在下文中一共展示了ODatabaseDocumentTx.countClass方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initializeData
import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx; //导入方法依赖的package包/类
@Override
public void initializeData() {
// Important! method is called without transaction to let implementation control transaction scope and type
// (initializer may even use many (different?) transactions).
// Unit of work must be defined before calling orient api: the simplest way is to use @Transactional
// on class or method
final ODatabaseDocumentTx db = context.getConnection();
if (db.countClass(ManualSchemeInitializer.CLASS_NAME) > 0) {
// perform initialization only in case of empty table
return;
}
// low level api used to insert records, but the same could be done with sql insert commands
for (int i = 0; i < 10; i++) {
final ODocument rec = db.newInstance(ManualSchemeInitializer.CLASS_NAME)
.field("name", "Sample" + i)
.field("amount", (int) (Math.random() * 200));
rec.save();
}
}
示例2: execute
import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx; //导入方法依赖的package包/类
public long execute(final ODatabaseDocumentTx db) {
checkNotNull(db);
return db.countClass(type);
}