java - performing create-or-update with jdbi -


For a small project, I decided to try (usually I work with Hibernate / JAPA) .

I like Lightweight, annotation based Dao creation using @ SqlUpdate / @ SqlQuery.

But: There are situations where I can not be sure that I want to make a unit or update the existing one. I keep a "selection" statement and use it on the basis of return value or update statement.

Q: Is it somehow supported by "interface-only" Dao in JDB? Or do I have to write the "create or update" method to write the self (making self-generated Dao more or less obsolete)?

Thanks for any indication.

Thanks to @Zolster, now I have created a solution based on an abstract class instead of the interface . Works as required

  @SqlUpdate ("Insert ...") Enter the public abstract zero (...); @SqlUpdate ("Update ...") Public Abstract Zero Update (); Make public X and upupdate (last XX) {if ((exists (x)) {insert (x);} and {update (x);} return search (...);}  

Comments