當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。