Using @Transaction in JDBI / Dropwizard application

LucaA picture LucaA · Nov 30, 2015 · Viewed 8k times · Source

I hava two jdbi dao like these:

public interface dao1 {
  @Query("insert into table1 ...")
  findByid(myBean1);
}

public interface dao2 {
  @Query("insert into table2 ...)
  save(myBean2;
  }
}

i want to execute save of two dao in one transaction like:

dao1.save();
dao2.save();

With spring i have used @transactional annotation. What can i do with dropwizard and jdbi ?

Answer

Manikandan picture Manikandan · Dec 3, 2015

You can use @Transaction in JDBI. I have blogged about it here. http://manikandan-k.github.io/2015/05/10/Transactions_in_jdbi.html