Tabnine Logo
BatchInsertGenKeysOp$FjList
Code IndexAdd Tabnine to your IDE (free)

How to use
BatchInsertGenKeysOp$FjList
in
com.novarto.sanedbc.core.ops

Best Java code snippets using com.novarto.sanedbc.core.ops.BatchInsertGenKeysOp$FjList (Showing top 8 results out of 315)

origin: novarto-oss/sane-dbc

DB.transact(new BatchInsertGenKeysOp.FjList<>(
    "whatevs",
    x -> ps -> {
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 submitIsNotTransactional()
{
  DB<Unit> fail = insertKeysOp(arrayList("a", "b", "c")).bind(ignore -> new DB<Unit>()
  {
    @Override public Unit run(Connection c) throws SQLException
    {
      throw new SQLException("failed i have");
    }
  });
  swallow(() -> DB.submit(fail));
  assertThat(DB.submit(SELECT_ALL_IDS_OP), is(arrayList("a", "b", "c")));
  assertThat(DB.transact(SELECT_ALL_IDS_OP), is(arrayList("a", "b", "c")));
}
origin: novarto-oss/sane-dbc

public static DB<Unit> insertOrders(List<CreateOrder> newOrders)
{
  // insert all the orders via batch, return the ORDER_ID keys
  DB<List<Integer>> insertOrdersGetKeys = new BatchInsertGenKeysOp.FjList<>(
      "INSERT INTO ORDERS(USER_EMAIL, TEXT) VALUES(?, ?)",
      x -> ps -> {
        ps.setString(1, x.userEmail);
        ps.setString(2, x.text);
      },
      newOrders,
      rs -> rs.getInt(1)
  );
  return insertOrdersGetKeys.map(ignore -> Unit.unit());
}
origin: novarto-oss/sane-dbc

@Test
public void selectBy()
{
  DB<Unit> insertIt = insertKeysOp(list("a"))
      .bind(ids -> insertDataOp(ids.zip(list("my_description"))).map(ignore -> Unit.unit()));
  DB.submit(insertIt);
  List<String> descriptions = DB.submit(selectByDescOp("my_description"));
  assertEquals(list("my_description"), descriptions);
}
origin: novarto-oss/sane-dbc

@Test
public void chainedTransaction()
{
  DB<List<String>> readInserted = insertKeysOp(asList("a", "b", "c")).bind(ids ->
  {
    List<P2<Integer, String>> data = ids.zip(list("Pesho", "Gosho", "Dragan"));
    return insertDataOp(data).bind(whatever -> SELECT_ALL_DATA_OP);
  });
  List<String> result = DB.transact(readInserted);
  assertThat(result, is(list("Pesho", "Gosho", "Dragan")));
}
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

private static BatchInsertGenKeysOp.FjList<String, Integer> insertKeysOp(Iterable<String> dummys)
{
  return new BatchInsertGenKeysOp.FjList<>("INSERT INTO MySqlTest_IDS(DUMMY) VALUES (?)",
      x -> st -> st.setString(1, x), dummys, rs -> rs.getInt(1));
}
com.novarto.sanedbc.core.opsBatchInsertGenKeysOp$FjList

Most used methods

  • <init>
  • bind

Popular in Java

  • Running tasks concurrently on multiple threads
  • scheduleAtFixedRate (Timer)
  • findViewById (Activity)
  • addToBackStack (FragmentTransaction)
  • ObjectMapper (com.fasterxml.jackson.databind)
    ObjectMapper provides functionality for reading and writing JSON, either to and from basic POJOs (Pl
  • BufferedReader (java.io)
    Wraps an existing Reader and buffers the input. Expensive interaction with the underlying reader is
  • Modifier (javassist)
    The Modifier class provides static methods and constants to decode class and member access modifiers
  • JButton (javax.swing)
  • IOUtils (org.apache.commons.io)
    General IO stream manipulation utilities. This class provides static utility methods for input/outpu
  • Get (org.apache.hadoop.hbase.client)
    Used to perform Get operations on a single row. To get everything for a row, instantiate a Get objec
  • Top plugins for WebStorm
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