4/20/2010

Mirage: Simple SQL Centric DB Access Library

Today, I released Mirage ver 1.0.0.

Mirage is a simple SQL centric database access library. It has a following two features:

  • 2WaySQL
    The main feature of Mirage is 2WaySQL. This makes plain old SQL template, and it is executable using any SQL client tools because parameters and conditions are written as SQL comment.
  • SQL less Update
    Generally, update processing are simpler than search processing. However, especially, large INSERT SQL brings us the considerable pain. In the Mirage, you can insert / update / delete records using entity class (without SQL).

The main feature of Mirage is 2WaySQL. This makes plain old SQL template. See the following example:

SELECT * FROM BOOK
/*BEGIN*/
  WHERE
  /*IF author != null */
        AUTHOR = /*author*/'Naoki Takezoe'
  /*END*/
  /*IF minPrice != null */
    AND PRICE >= /*minPrice*/20
  /*END*/
  /*IF maxPrice != null */
    AND PRICE <= /*maxPrice*/100
  /*END*/
/*END*/
ORDER BY BOOK_ID ASC

Mirage processes this SQL template and executes it using PreparedStatement at runtime. And this SQL template is exacutable even it is on SQL client tools such as SQL*Plus(Oracle) or psql(PostgreSQL). So it makes easy to test SQL.

See details about Mirage at our web site. I would also talk about Mirage in this blog.

2 件のコメント:

Adrian A. さんのコメント...

Very very nice framework :).

I few "features" that would be also very nice and helpful:
1. A download link from the menu.

2. Support for relationships. E.g.

class Author {
private String firstName;
private String lastName;
private Date birthDate;
}
class Book {
...
private Author author;
...
}

to be fetched automatically and smartly with one select - not just the book object, but the Author object too.

3. It would be nice if it wouldn't be dependent on 'logback'

4. "offline/compiler" mode. i.e. to generate the SQLs at "compile" time, not at runtime, with a ANT task (thus having at runtime no extra dependencies). Something like the JSP compiler does.

5. A complete example with Click Framework :).

Thank you,
Adrian.

Naoki Takezoe さんのコメント...

Thanks Adrian,

Mirage 1.0.0 has only minimum features. So I wish to improve it continuous.
However, I want to think about relationship support carefully because it may bring complexity into Mirage.