InterviewSolution
| 1. |
What Is Sql Object Style (declarative) Api Of Jdbi? |
|
Answer» The SQL Object extension sits atop Core, and provides a declarative interface. Tell Jdbi what SQL to execute and the shape of the results you LIKE by declaring an annotated Java interface, and it will provide the IMPLEMENTATION. // Define your own declarative interface public interface UserDao { @SqlUpdate("CREATE TABLE user (id INTEGER PRIMARY KEY, name VARCHAR)") void createTable(); @SqlUpdate("INSERT INTO user(id, name) VALUES (?, ?)") void insertPositional(INT id, String name); } The SQL Object extension sits atop Core, and provides a declarative interface. Tell Jdbi what SQL to execute and the shape of the results you like by declaring an annotated Java interface, and it will provide the implementation. // Define your own declarative interface public interface UserDao { @SqlUpdate("CREATE TABLE user (id INTEGER PRIMARY KEY, name VARCHAR)") void createTable(); @SqlUpdate("INSERT INTO user(id, name) VALUES (?, ?)") void insertPositional(int id, String name); } |
|