6/03/2010

Mirage supports stored procedure/function

The next version of Mirage will support stored procedure/function. We added new methods to call them to SqlManager in the SVN trunk.

Here is an example to call stored function in Mirage:

// Creates parameter object which give to stored function
GetCountParam param = new GetCountParam();
param.deptId = 1;
...
// Calls a stored function and get a result value.
Long count = sqlManager.call(Long.class, "get_emp_count", param);

Fields of the parameter class has annotation such as @In, @Out, @InOut and @ResultSet. These annotations mean parameter type.

If the function returns ResultSet, use SqlManager#callForList() instead of SqlManager#call().

Please wait for the next release of Mirage!

5/09/2010

Large results processing in Mirage

The next release of Mirage is 1.0.3. It contains some new features. Today, I write about iteration search which is one of them.

SqlManager#getResultList() creates all entity instances and returns a list which contains them. If SQL returns a large result, it causes OutOfMemory.

In these case, you should use SqlManager#iterate() instead of SqlManager#getResultList().

Integer result = sqlManager.iterate(
  Book.class,
  new IterationCallback<Book, Integer>() {

    private int result;

    @Override public Integer iterate(Book entity) {
      result = result + entity.price;
      return result;
    }

  },
  SQL_PREFIX + "SqlManagerImplTest_selectBooks.sql");

SqlManager#iterate() accepts IterationCallback and invoke it per record. The return value of SqlManager#iterate() is a last returned value from IterationCallback.

Iteration search would be available in Mirage 1.0.3.

5/08/2010

Mirage 1.0.2 Released!

Mirage 1.0.2 is now available!

Mirage is a simple SQL centric database access library. See the following URL to know about Mirage:

1.0.2 is a maintenance release. Here is the list of changes in this release:

  • Dependency to Spring Framework and Guice became optional.
  • Dependency to the pached OGNL changed to OGNL 2.7.3.
  • BugFix about BLOB support.

BLOB support in 1.0.1 does not work because it contains a serious bug. This bug was fixed in 1.0.2 and dependencies was reviewed and modified to minimum.

And also Mirage with Apache Click example is released. You can get it from the download page.

I wish that Mirage helps your development. Enjoy!

5/02/2010

Mirage and Apache Click Example

I started to make a sample application to use Mirage with Apache Click.

This sample application has not been completed yet. However you can checkout source code from the following URL using Subversion.

You can build a war file using Maven. Please execute following commands in command prompt.

$ svn co http://svn.sourceforge.jp/svnroot/amateras/mirage/trunk/mirage-click-example/
$ cd mirage-click-example
$ mvn package

Then you can find mirage-click-example.war in the /target directory.

Put it into the application server such as Tomcat and access http://localhost:8080/mirage-click-example/ using your browser.

Mirage 1.0.1 Released!

Mirage is a simple SQL centric database access library. Today, I've just released Mirage 1.0.1. It's already available.

See the following URL to know about Mirage:

Here is the list of new features in this release:

  • Use java.util.logging instead of slf4j / logback to remove them from dependency.
  • Simple example and documentation for Google Guice integration.
  • It's possible to specify a transient property by transient modifier instead of @Transient annotation.
  • Add new method SqlManager#findEntity(Class clazz, Object... id)
  • Add new method SqlManager#getCount(String sqlPath[, Object param])
  • ValueType interface to add custome value type support
  • BLOB support

Mirage is still not enough to use in complex systems. So we would improve it as much as possible soon.

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.

4/18/2010

Java Standard EL Functions 1.1.0 is available!

We released Java Standard EL Functions (JSEL) ver 1.1.0.

JSEL provides standard JSP-EL functions for web application development such as escaping HTML tags, URL encoding and formatting Date or Number. You can use it with many web frameworks which use JSP as view technologies.

Here is the example to JSEL usage:

<%@ taglib uri="http://amateras.sf.jp/functions" prefix="f" %>
...
<%-- Escape HTML tags --%>
${f:h(value)}
<%-- URL encode --%>
${f:u(value)}

JSEL provides many usable EL functions. Please check our web site to know details about JSEL.