本文整理汇总了Java中com.sleepycat.persist.PrimaryIndex.delete方法的典型用法代码示例。如果您正苦于以下问题:Java PrimaryIndex.delete方法的具体用法?Java PrimaryIndex.delete怎么用?Java PrimaryIndex.delete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sleepycat.persist.PrimaryIndex
的用法示例。
在下文中一共展示了PrimaryIndex.delete方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testAutoOpenRelatedEntity
import com.sleepycat.persist.PrimaryIndex; //导入方法依赖的package包/类
/**
* When Y is opened and X has a key with relatedEntity=Y.class, X should
* be opened automatically. If X is not opened, foreign key constraints
* will not be enforced. [#15358]
*/
public void testAutoOpenRelatedEntity()
throws DatabaseException {
PrimaryIndex<Integer,RelatedY> priY;
PrimaryIndex<Integer,RelatedX> priX;
/* Opening X should create (and open) Y and enforce constraints. */
open();
priX = store.getPrimaryIndex(Integer.class, RelatedX.class);
PersistTestUtils.assertDbExists
(true, env, STORE_NAME, RelatedY.class.getName(), null);
try {
priX.put(new RelatedX());
fail();
} catch (DatabaseException e) {
assertTrue
(e.getMessage().indexOf
("foreign key not allowed: it is not present") > 0);
}
priY = store.getPrimaryIndex(Integer.class, RelatedY.class);
priY.put(new RelatedY());
priX.put(new RelatedX());
close();
/* Delete should cascade even when X is not opened explicitly. */
open();
priY = store.getPrimaryIndex(Integer.class, RelatedY.class);
assertEquals(1, priY.count());
priY.delete(88);
assertEquals(0, priY.count());
priX = store.getPrimaryIndex(Integer.class, RelatedX.class);
assertEquals(0, priX.count()); /* Failed prior to [#15358] fix. */
close();
}
示例2: testAutoOpenRelatedEntity
import com.sleepycat.persist.PrimaryIndex; //导入方法依赖的package包/类
/**
* When Y is opened and X has a key with relatedEntity=Y.class, X should
* be opened automatically. If X is not opened, foreign key constraints
* will not be enforced. [#15358]
*/
public void testAutoOpenRelatedEntity()
throws DatabaseException {
PrimaryIndex<Integer,RelatedY> priY;
PrimaryIndex<Integer,RelatedX> priX;
/* Opening X should create (and open) Y and enforce constraints. */
open();
priX = store.getPrimaryIndex(Integer.class, RelatedX.class);
PersistTestUtils.assertDbExists
(true, env, STORE_NAME, RelatedY.class.getName(), null);
try {
priX.put(new RelatedX());
fail();
} catch (DatabaseException e) {
assertTrue
("" + e.getMessage(), (e.getMessage().indexOf
("foreign key not allowed: it is not present") >= 0) ||
(e.getMessage().indexOf("DB_FOREIGN_CONFLICT") >= 0));
}
priY = store.getPrimaryIndex(Integer.class, RelatedY.class);
priY.put(new RelatedY());
priX.put(new RelatedX());
close();
/* Delete should cascade even when X is not opened explicitly. */
open();
priY = store.getPrimaryIndex(Integer.class, RelatedY.class);
assertEquals(1, priY.count());
priY.delete(88);
assertEquals(0, priY.count());
priX = store.getPrimaryIndex(Integer.class, RelatedX.class);
assertEquals(0, priX.count()); /* Failed prior to [#15358] fix. */
close();
}