}
@Test
public void should_batch_counters() throws Exception {
// Start batch
Batch batch = manager.createBatch();
batch.startBatch();
CompleteBean entity = CompleteBeanTestBuilder.builder().randomId().name("name").buid();
entity = batch.insert(entity);
entity.setLabel("label");
Tweet welcomeTweet = TweetTestBuilder.tweet().randomId().content("welcomeTweet").buid();
entity.setWelcomeTweet(welcomeTweet);
entity.getVersion().incr(10L);
batch.update(entity);
final RegularStatement selectLabel = select("label").from("CompleteBean").where(eq("id", entity.getId()));
Map<String, Object> result = manager.nativeQuery(selectLabel).first();
assertThat(result).isNull();
RegularStatement selectCounter = select("counter_value").from("achilles_counter_table")
.where(eq("fqcn", CompleteBean.class.getCanonicalName()))
.and(eq("primary_key", entity.getId().toString()))
.and(eq("property_name", "version"));
result = manager.nativeQuery(selectCounter).first();
assertThat(result).isNull();
// Flush
batch.endBatch();
Row row = manager.getNativeSession().execute(selectLabel).one();
assertThat(row.getString("label")).isEqualTo("label");
result = manager.nativeQuery(selectCounter).first();