iDao - a New Way of Data Access Object Development
Join the DZone community and get the full member experience.
Join For FreeI developed a new tiny library, iDao, to help developing data access object.
Here's what the code looks like by using iDao.
public interface TestDao { @Update("INSERT INTO TEST_TABLE (COL_ONE, COL_TWO) VALUES (?<1>?, ?<2>?)") int insertDataWithIndexParameter(int intValue, String varcharValue); @Update("INSERT INTO TEST_TABLE (COL_ONE, COL_TWO) VALUES (?<fieldone>?, ?<fieldtwo>?)") void insertDataWithBeanParameter(TestBean bean); @Query("select COL_ONE from TEST_TABLE") List<integer> findAllIntColumns(); @Query("select col_two from test_table where COL_ONE=?<1>? and COL_TWO=?<2>?") List<string> findStringColumnsWithIndexParameter(int intValue, String varcharValue); @Query("select COL_ONE fieldOne, COL_TWO fieldTwo from TEST_TABLE where COL_ONE = ?<fieldone>?") List<testbean> findIntoBeanWithBeanParameter(TestBean bean); @Query("select COL_TWO fieldTwo from TEST_TABLE where COL_ONE = ?<1.fieldOne>?") String findSimpleValueWithIndexedBeanParameter(TestBean bean); } </testbean></fieldone></string></integer></fieldtwo></fieldone>
Yes, just
- declare the DAO interfaces that are called by Service layer, and
- methods used to access database, and
- SQL statement to be executed by each method and arguments if any.
Please take a look at the Getting Started guide on the project's website and tell me if this is useful. If it is I'd be more than happy and will give me motivation to keep improving it, to make it better.
Thanks a lot!
Data access
Data access object
Data (computing)
Object (computer science)
Opinions expressed by DZone contributors are their own.
Comments