@Test public void testDeletePojo() { PojoDao<Person> dao = createPojoDao(Person.class); Person pojo = new Person("Slappy", "White"); dao.save(pojo); assertNotNull(dao.findByKey(pojo.getId())); dao.delete(pojo); assertNull(dao.findByKey(pojo.getId())); }
private <T> void deletePojo(T pojo, PojoBinding<T> pojoBinding, String tableName, UpdateGroup group, StatementOptions options) { PreparedStatement delete = statementFactory.createDelete(pojoBinding, tableName); List<Object> keys = new LinkedList<>(); pojoBinding.getKeyBinding().collectParameters(pojo, keys); BoundStatement statement = pojoBinding.bindWhereIdEquals(delete, keys); options.applyTo(statement); group.addUpdate(statement); }
DefaultPojoDao implements PojoDao<P> { private <T> void deletePojo(T pojo, PojoBinding<T> pojoBinding, String tableName, UpdateGroup group, StatementOptions options) { PreparedStatement delete = statementFactory.createDelete(pojoBinding, tableName); List<Object> keys = new LinkedList<>(); pojoBinding.getKeyBinding().collectParameters(pojo, keys); BoundStatement statement = pojoBinding.bindWhereIdEquals(delete, keys); options.applyTo(statement); group.addUpdate(statement); } }
DefaultPojoDao implements PojoDao<P> { private <T> void deletePojo(T pojo, PojoBinding<T> pojoBinding, String tableName, UpdateGroup group, StatementOptions options) { PreparedStatement delete = statementFactory.createDelete(pojoBinding, tableName); List<Object> keys = new LinkedList<>(); pojoBinding.getKeyBinding().collectParameters(pojo, keys); BoundStatement statement = pojoBinding.bindWhereIdEquals(delete, keys); options.applyTo(statement); group.addUpdate(statement); } DefaultPojoDao(Session session, PojoBinding<P> binding, String tableName, PojoStatementFactory statementFactory, PojoQueryContextFactory contextFactory, Executor executor); }
DefaultPojoDao implements PojoDao<P> { private <T> void deletePojo(T pojo, PojoBinding<T> pojoBinding, String tableName, UpdateGroup group, StatementOptions options) { PreparedStatement delete = statementFactory.createDelete(pojoBinding, tableName); List<Object> keys = new LinkedList<>(); pojoBinding.getKeyBinding().collectParameters(pojo, keys); BoundStatement statement = pojoBinding.bindWhereIdEquals(delete, keys); options.applyTo(statement); group.addUpdate(statement); } DefaultPojoDao(Session session, PojoBinding<P> binding, String tableName, PojoStatementFactory statementFactory, PojoQueryContextFactory contextFactory, Executor executor); @Override void delete(P pojo); @Override void delete(StatementOptions options, P pojo); @Override void delete(UpdateGroup group, P pojo); @Override void delete(UpdateGroup group, StatementOptions options, P pojo); @Override ListenableFuture<Void> deleteAsync(P pojo); @Override ListenableFuture<Void> deleteAsync(StatementOptions options, P pojo); @Override void deleteByKey(Object... values); @Override void deleteByKey(StatementOptions options, Object... values); @Override void deleteByKey(UpdateGroup group, StatementOptions options, Object... values); @Override ListenableFuture<Void> deleteByKeyAsync(Object... values); @Override ListenableFuture<Void> deleteByKeyAsync(StatementOptions options, Object... values); @Override PojoQueryBuilder<P> find(); @Override PojoQuery<P> find(Consumer<Select.Where> builder); @Override P findByKey(Object... values); @Override P findByKey(StatementOptions options, Object... values); @Override PojoMultiQuery<P> findByKeys(); @Override PojoMultiQuery<P> findByKeys(StatementOptions options); @Override void save(P pojo); @Override void save(P pojo, int ttl); @Override void save(StatementOptions options, P pojo); @Override void save(UpdateGroup group, P pojo); @Override void save(StatementOptions options, P pojo, int ttl); @Override void save(UpdateGroup group, P pojo, int ttl); @Override void save(UpdateGroup group, StatementOptions options, P pojo); @Override void save(UpdateGroup group, StatementOptions options, P pojo, int ttl); @Override ListenableFuture<Void> saveAsync(P pojo); @Override ListenableFuture<Void> saveAsync(P pojo, int ttl); @Override ListenableFuture<Void> saveAsync(StatementOptions options, P pojo); @Override ListenableFuture<Void> saveAsync(StatementOptions options, P pojo, int ttl); }
DefaultPojoDao implements PojoDao<P> { private <T> void deletePojo(T pojo, PojoBinding<T> pojoBinding, String tableName, UpdateGroup group, StatementOptions options) { PreparedStatement delete = statementFactory.createDelete(pojoBinding, tableName); List<Object> keys = new LinkedList<>(); pojoBinding.getKeyBinding().collectParameters(pojo, keys); BoundStatement statement = pojoBinding.bindWhereIdEquals(delete, keys); options.applyTo(statement); group.addUpdate(statement); } DefaultPojoDao(Session session, PojoBinding<P> binding, String tableName, PojoStatementFactory statementFactory, PojoQueryContextFactory contextFactory, Executor executor); @Override void delete(P pojo); @Override void delete(StatementOptions options, P pojo); @Override void delete(UpdateGroup group, P pojo); @Override void delete(UpdateGroup group, StatementOptions options, P pojo); @Override ListenableFuture<Void> deleteAsync(P pojo); @Override ListenableFuture<Void> deleteAsync(StatementOptions options, P pojo); @Override void deleteByKey(Object... values); @Override void deleteByKey(StatementOptions options, Object... values); @Override void deleteByKey(UpdateGroup group, StatementOptions options, Object... values); @Override ListenableFuture<Void> deleteByKeyAsync(Object... values); @Override ListenableFuture<Void> deleteByKeyAsync(StatementOptions options, Object... values); @Override PojoQueryBuilder<P> find(); @Override PojoQuery<P> find(Consumer<Select.Where> builder); @Override P findByKey(Object... values); @Override P findByKey(StatementOptions options, Object... values); @Override PojoMultiQuery<P> findByKeys(); @Override PojoMultiQuery<P> findByKeys(StatementOptions options); @Override void save(P pojo); @Override void save(P pojo, int ttl); @Override void save(StatementOptions options, P pojo); @Override void save(UpdateGroup group, P pojo); @Override void save(StatementOptions options, P pojo, int ttl); @Override void save(UpdateGroup group, P pojo, int ttl); @Override void save(UpdateGroup group, StatementOptions options, P pojo); @Override void save(UpdateGroup group, StatementOptions options, P pojo, int ttl); @Override ListenableFuture<Void> saveAsync(P pojo); @Override ListenableFuture<Void> saveAsync(P pojo, int ttl); @Override ListenableFuture<Void> saveAsync(StatementOptions options, P pojo); @Override ListenableFuture<Void> saveAsync(StatementOptions options, P pojo, int ttl); static final int NO_TTL; }