Tabnine Logo
AggregateOp
Code IndexAdd Tabnine to your IDE (free)

How to use
AggregateOp
in
com.novarto.sanedbc.core.ops

Best Java code snippets using com.novarto.sanedbc.core.ops.AggregateOp (Showing top 5 results out of 315)

origin: novarto-oss/sane-dbc

public static DB<Long> count(String like)
{
  String searchQuery = like.trim();
  //an aggregate op expects the resultset to have one element, and that element to be cast to long
  //useful for numeric aggregate operations
  return new AggregateOp("SELECT COUNT(*) FROM STUFF WHERE LOWER(DESCRIPTION) LIKE LOWER(?)",
      ps -> ps.setString(1, searchQuery + "%")
  );
}
origin: novarto-oss/sane-dbc

@Test
public void rollback()
{
  DB<List<Long>> insertDataFail = insertKeysOp(list("okidoki")).bind(ids -> fail("failed i have"));
  swallow(() -> DB.transact(insertDataFail));
  DB<P2<Long, Long>> tryCounts = COUNT_IDS.bind(idCount -> COUNT_DATA.map(dataCount -> p(idCount, dataCount)));
  P2<Long, Long> counts = DB.submit(tryCounts);
  assertEquals(0, (long) counts._1());
  assertEquals(0, (long) counts._2());
}
origin: novarto-oss/sane-dbc

@Test
public void rollback2()
{
  DB<Unit> failedInsert = insertKeysOp(list("ok"))
      .bind(ids -> insertDataOp(ids.zip(list("description"))).bind(insertCount ->
      {
        throw new RuntimeException("failed I have");
      }));
  swallow(() -> DB.transact(failedInsert));
  DB<P2<Long, Long>> tryCounts = COUNT_IDS.bind(idCount -> COUNT_DATA.map(dataCount -> p(idCount, dataCount)));
  P2<Long, Long> counts = DB.submit(tryCounts);
  assertEquals(0, (long) counts._1());
  assertEquals(0, (long) counts._2());
}
origin: novarto-oss/sane-dbc

@Test
public void checkMigrationsAreApplied()
{
  SyncDbInterpreter dbi = new SyncDbInterpreter(
      // provide a piece of code which knows how to spawn connections
      // in this case we are just using the DriverManager
      () -> DriverManager.getConnection(FLYWAY_JDBC_URL, "sa", "")
  );
  // check that after flyway migrations are applied the count of FOO is 3
  final Long count = dbi.submit(new AggregateOp("SELECT COUNT(*) FROM FLYWAY.FOO"));
  assertThat(count, is(3L));
}
origin: novarto-oss/sane-dbc

Long count = sync.submit(new AggregateOp("SELECT COUNT(*) FROM DUMMY"));
assertThat(count, is(1L));
  count = sync.submit(new AggregateOp("SELECT COUNT(*) FROM DUMMY"));
Validation<Exception, Long> successExpected = vdb.submit(new AggregateOp("SELECT COUNT(*) FROM DUMMY")).f();
assertThat(successExpected.isSuccess(), is(true));
assertThat(successExpected.success(), is(1L));
  CompletableFuture<Long> countFuture = async.submit(new AggregateOp("SELECT COUNT(*) FROM DUMMY"));
  CompletableFuture<Long> failedFuture = async.submit(new AggregateOp("BLA BLA BLA"));
com.novarto.sanedbc.core.opsAggregateOp

Most used methods

  • <init>
  • bind
  • map

Popular in Java

  • Parsing JSON documents to java classes using gson
  • scheduleAtFixedRate (Timer)
  • setRequestProperty (URLConnection)
  • setScale (BigDecimal)
  • NumberFormat (java.text)
    The abstract base class for all number formats. This class provides the interface for formatting and
  • LinkedList (java.util)
    Doubly-linked list implementation of the List and Dequeinterfaces. Implements all optional list oper
  • SortedMap (java.util)
    A map that has its keys ordered. The sorting is according to either the natural ordering of its keys
  • TimerTask (java.util)
    The TimerTask class represents a task to run at a specified time. The task may be run once or repeat
  • Notification (javax.management)
  • LogFactory (org.apache.commons.logging)
    Factory for creating Log instances, with discovery and configuration features similar to that employ
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now