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


Java TooManyRowsException类代码示例

本文整理汇总了Java中org.jooq.exception.TooManyRowsException的典型用法代码示例。如果您正苦于以下问题:Java TooManyRowsException类的具体用法?Java TooManyRowsException怎么用?Java TooManyRowsException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: fetchOneByConditionWithMultipleMatchesShouldFail

import org.jooq.exception.TooManyRowsException; //导入依赖的package包/类
@Test
public void fetchOneByConditionWithMultipleMatchesShouldFail() throws InterruptedException {
    CountDownLatch latch = new CountDownLatch(1);
    Future<Integer> insertFuture1 = Future.future();
    Future<Integer> insertFuture2 = Future.future();

    Something someNewObject = createSomething();
    dao.insertReturningPrimaryAsync(someNewObject,insertFuture1);
    dao.insertReturningPrimaryAsync(createSomething().setSomehugenumber(someNewObject.getSomehugenumber()),insertFuture2);
    CompositeFuture.all(insertFuture1,insertFuture2).
            setHandler(consumeOrFailHandler(v->{
                dao.fetchOneAsync(Tables.SOMETHING.SOMEHUGENUMBER.eq(someNewObject.getSomehugenumber()),h->{
                    Assert.assertNotNull(h.cause());
                    //cursor fetched more than one row
                    Assert.assertEquals(TooManyRowsException.class, h.cause().getClass());
                    dao.deleteExecAsync(Tables.SOMETHING.SOMEHUGENUMBER.eq(someNewObject.getSomehugenumber()),countdownLatchHandler(latch));
                });
            }));
    await(latch);
}
 
开发者ID:jklingsporn,项目名称:vertx-jooq-async,代码行数:21,代码来源:VertxSomethingDaoTest.java

示例2: fetchOne

import org.jooq.exception.TooManyRowsException; //导入依赖的package包/类
@Override
public <P> void fetchOne(Query query, Function<JsonObject, P> mapper, Handler<AsyncResult<P>> resultHandler) {
    getConnection().setHandler(sqlConnectionResult->{
        if(sqlConnectionResult.succeeded()){
            log("Fetch one", ()-> query.getSQL(ParamType.INLINED));
            sqlConnectionResult.result().queryWithParams(
                    query.getSQL(),
                    getBindValues(query),
                    executeAndClose(rs -> {
                                if(rs.getRows().size() > 1){
                                    throw new TooManyRowsException(String.format("Got more than one row: %d",rs.getRows().size()));
                                }
                                Optional<P> optional = rs.getRows().stream().findFirst().map(mapper);
                                return (optional.orElseGet(() -> null));
                            },
                            sqlConnectionResult.result(),
                            resultHandler)
            );
        }else{
            resultHandler.handle(Future.failedFuture(sqlConnectionResult.cause()));
        }
    });
}
 
开发者ID:jklingsporn,项目名称:vertx-jooq-async,代码行数:24,代码来源:AsyncJooqSQLClientImpl.java

示例3: fetchOneByConditionWithMultipleMatchesShouldFail

import org.jooq.exception.TooManyRowsException; //导入依赖的package包/类
@Test
public void fetchOneByConditionWithMultipleMatchesShouldFail() throws InterruptedException {
    CountDownLatch latch = new CountDownLatch(1);
    CompletableFuture<Integer> insertFuture1 = dao.insertReturningPrimaryAsync(createSomething().setSomehugenumber(1L));
    CompletableFuture<Integer> insertFuture2 = dao.insertReturningPrimaryAsync(createSomething().setSomehugenumber(1L));
    CompletableFuture.allOf(insertFuture1, insertFuture2).
            thenCompose(v->dao.fetchOneAsync(Tables.SOMETHING.SOMEHUGENUMBER.eq(1L))).
            exceptionally((x) -> {
                Assert.assertNotNull(x);
                //cursor fetched more than one row
                Assert.assertEquals(TooManyRowsException.class, x.getCause().getClass());
                return null;}).
            thenCompose(v -> dao.deleteExecAsync(Tables.SOMETHING.SOMEHUGENUMBER.eq(1L))).
            whenComplete(failOrCountDown(latch));
    await(latch);
}
 
开发者ID:jklingsporn,项目名称:vertx-jooq-async,代码行数:17,代码来源:VertxSomethingDaoTest.java

示例4: fetchOneByConditionWithMultipleMatchesShouldFail

import org.jooq.exception.TooManyRowsException; //导入依赖的package包/类
@Test
public void fetchOneByConditionWithMultipleMatchesShouldFail() throws InterruptedException {
    CountDownLatch latch = new CountDownLatch(1);
    Single<Integer> insert1 = dao.insertReturningPrimaryAsync(createSomething().setSomehugenumber(1L));
    Single<Integer> insert2 = dao.insertReturningPrimaryAsync(createSomething().setSomehugenumber(1L));


    Single.zip(insert1, insert2, (i1, i2) -> i1)
        .flatMap(i -> dao.fetchOneAsync(Tables.SOMETHING.SOMEHUGENUMBER.eq(1L)))
        .onErrorReturn(x -> {
            Assert.assertNotNull(x);
            Assert.assertEquals(TooManyRowsException.class, x.getClass());
            return null;
        })
        .flatMap(n -> dao.deleteExecAsync(Tables.SOMETHING.SOMEHUGENUMBER.eq(1L)))
        .subscribe(failOrCountDownSingleObserver(latch));

    await(latch);
}
 
开发者ID:jklingsporn,项目名称:vertx-jooq-async,代码行数:20,代码来源:VertxSomethingDaoTest.java

示例5: fetchOneByConditionWithMultipleMatchesShouldFail

import org.jooq.exception.TooManyRowsException; //导入依赖的package包/类
@Test
public void fetchOneByConditionWithMultipleMatchesShouldFail() throws InterruptedException {
    CountDownLatch latch = new CountDownLatch(1);
    long num = NUMBERS.incrementAndGet();
    Single<Integer> insert1 = dao.insertReturningPrimaryAsync(createSomething().setSomehugenumber(num));
    Single<Integer> insert2 = dao.insertReturningPrimaryAsync(createSomething().setSomehugenumber(num));


    Single.zip(insert1, insert2, (i1, i2) -> i1)
        .flatMap(i -> dao.fetchOneAsync(Tables.SOMETHING.SOMEHUGENUMBER.eq(num)))
        .onErrorReturn(x -> {
            Assert.assertNotNull(x);
            Assert.assertEquals(TooManyRowsException.class, x.getClass());
            //must return a non-null value...
            return createSomething();
        })
        .flatMap(n -> dao.deleteExecAsync(Tables.SOMETHING.SOMEHUGENUMBER.eq(num)))
        .subscribe(failOrCountDownSingleObserver(latch));

    await(latch);
}
 
开发者ID:jklingsporn,项目名称:vertx-jooq,代码行数:22,代码来源:VertxSomethingDaoTest.java

示例6: fetchOneByConditionWithMultipleMatchesShouldFail

import org.jooq.exception.TooManyRowsException; //导入依赖的package包/类
@Test
public void fetchOneByConditionWithMultipleMatchesShouldFail() throws InterruptedException {
    CountDownLatch latch = new CountDownLatch(1);
    Future<Integer> insertFuture1 = Future.future();
    Future<Integer> insertFuture2 = Future.future();
    dao.insertReturningPrimaryAsync(createSomething().setSomehugenumber(1L),insertFuture1);
    dao.insertReturningPrimaryAsync(createSomething().setSomehugenumber(1L),insertFuture2);
    CompositeFuture.all(insertFuture1,insertFuture2).
            setHandler(consumeOrFailHandler(v->{
                dao.fetchOneAsync(Tables.SOMETHING.SOMEHUGENUMBER.eq(1L),h->{
                    Assert.assertNotNull(h.cause());
                    //cursor fetched more than one row
                    Assert.assertEquals(TooManyRowsException.class, h.cause().getClass());
                    dao.deleteExecAsync(Tables.SOMETHING.SOMEHUGENUMBER.eq(1L),countdownLatchHandler(latch));
                });
            }));
    await(latch);
}
 
开发者ID:jklingsporn,项目名称:vertx-jooq,代码行数:19,代码来源:VertxSomethingDaoTest.java

示例7: checkPermission

import org.jooq.exception.TooManyRowsException; //导入依赖的package包/类
private boolean checkPermission(List<Agency> agencies,
                                Relationship permission,
                                UUID intrinsic) throws DataAccessException,
                                                TooManyRowsException {
    if (intrinsic == null) {
        return true;
    }
    List<UUID> roles = agencies.stream()
                               .map(r -> r.getId())
                               .collect(Collectors.toList());
    ExistentialNetwork membership = EXISTENTIAL_NETWORK.as(MEMBERSHIP);
    CommonTableExpression<Record1<UUID>> groups = name(GROUPS).fields(AGENCY)
                                                              .as(create.select(membership.field(membership.CHILD))
                                                                        .from(membership)
                                                                        .where(membership.field(membership.PARENT)
                                                                                         .in(roles))
                                                                        .and(membership.field(membership.RELATIONSHIP)
                                                                                       .equal(WellKnownRelationship.MEMBER_OF.id())));

    return ZERO.equals(create.with(groups)
                             .selectCount()
                             .from(EXISTENTIAL)
                             .where(EXISTENTIAL.ID.equal(intrinsic))
                             .andNotExists(create.select(EXISTENTIAL_NETWORK.CHILD)
                                                 .from(EXISTENTIAL_NETWORK)
                                                 .where(EXISTENTIAL_NETWORK.PARENT.in(create.selectFrom(groups))
                                                                                  .or(EXISTENTIAL_NETWORK.PARENT.in(roles)))
                                                 .and(EXISTENTIAL_NETWORK.RELATIONSHIP.equal(permission.getId()))
                                                 .and(EXISTENTIAL_NETWORK.CHILD.eq(EXISTENTIAL.ID)))
                             .fetchOne()
                             .value1());
}
 
开发者ID:ChiralBehaviors,项目名称:Ultrastructure,代码行数:33,代码来源:ModelImpl.java


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