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


Java PrimaryIndex.delete方法代码示例

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

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


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