- Add the Codota plugin to your IDE and get smart completions
private void myMethod () {ArrayList a =
new ArrayList<String>()
new ArrayList()
new ArrayList<Object>()
- Smart code suggestions by Codota
}
public static DB<Integer> insertStuffGetKey(String description) { /* An InsertGenKeysOp is the same as an UpdateOp, only that it expects an auto-generated key to be present after executing the update, and returns it as the result. InsertGenKeysOp.Int is a specialization which expects an Integer key */ return new InsertGenKeysOp.Int( "INSERT INTO STUFF(DESCRIPTION) VALUES(?)", // you can see that the binder is the same as in the previous operation. // in that case it is good practice to extract it as a static final field of your module ps -> ps.setString(1, description) ); }
@Test public void insertGenKeys() { Integer id = DB.transact(new InsertGenKeysOp.Int( "INSERT INTO MySqlTest_IDS(DUMMY) VALUES (?)", ps -> ps.setString(1, "a"))); assertThat(id, is(notNullValue())); String str = DB.submit(DbOps .unique(new SelectOp.List<>("SELECT DUMMY FROM MySqlTest_IDS WHERE ID=?", ps -> ps.setInt(1, id), rs -> rs.getString(1)))).some(); assertThat(str, is("a")); }