DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone >

iDao - a New Way of Data Access Object Development

Shaket Baby user avatar by
Shaket Baby
·
Sep. 27, 09 · · News
Like (0)
Save
Tweet
588 Views

Join the DZone community and get the full member experience.

Join For Free

I 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
  1. declare the DAO interfaces that are called by Service layer, and
  2. methods used to access database, and
  3. SQL statement to be executed by each method and arguments if any.
That's it, no implementation, iDao will generate one at runtime and takes care of any other things.

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.

Popular on DZone

  • Building a Login Screen With React and Bootstrap
  • Transactions vs. Analytics in Apache Kafka
  • Take Control of Your Application Security
  • Upload Files to AWS S3 in JMeter Using Groovy

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo