@Test
public final void storeAndRemoveWithoutAop() {
Injector injector = Guice.createInjector(new SqlModule(config));
createTable(injector);
Persister persister = injector.getInstance(Persister.class);
persister.call(new Persister.InWork() {
@Override
public Object perform(EntityStore es) throws Throwable {
((Sql)es.delegate()).execute("insert into my_table (id, name) values (1, @name)",
ImmutableMap.<String, Object>of("name", A_NAME));
return null;
}
});
persister.call(new Persister.InWork() {
@Override
public Object perform(EntityStore es) throws Throwable {
((Sql)es.delegate()).execute("delete from my_table where name = @name and id = @id",
ImmutableMap.<String, Object>of(
"id", 1,
"name", A_NAME
));
return null;
}
});
Object param = persister.call(new Persister.InWork() {
@Override
public Object perform(EntityStore es) throws Throwable {
return ((Sql)es.delegate()).list("select * from my_table");
}
});