Monday, May 28, 2007

Perl DBI Module - Examples

I found nice article about Perl DBI Module. If you would like to know how to set up autocommit, bind values, manage transactions or call stored procedures then you should not miss this document:

BTW: This is a good example of KISS style document.

Sunday, May 27, 2007

Java Persistence Query Returning Simple Custom Object

Consider the following situation: We needed to retrieve just a small fraction of information from the database about particular business objects and transmit this data over network. It is probably not very surprising that the following query:

Query q1 = em.createQuery("SELECT, e.salary FROM Employee e");

returns List of Object[] instances. OK, what if we would like to return something much simpler then our original Employee object but still more concrete then general Object type? I found there is one very easy and effective solution:

Query q = em.createQuery(
"NEW mypackage.EmployeeDetail(,, e.salary) " +
"FROM Employee e");
List<EmployeeDetail> result = q.getResultList();

The mypackage.EmployeeDetail object is just POJO object with particular constructor without any JPA annotations or mapping file.

(Source: Michael Bouschen's Blog - Java Persistence Query Return Types)

Saturday, May 26, 2007

Groovy things to do with Groovy

A very nice Tech Talk about upcoming Groovy 1.1 release.
(Source: blog - which in my opinion is another page worth reading.)
However; code samples in this presentation are too small to read :-(

Wednesday, May 23, 2007

Spider Cat

Spider Cat
Originally uploaded by Lukáš Vlček.
I didn't know we have a very special neighbor until recently. It seems that this cat has been watching us for a years without our knowledge!

Tuesday, May 8, 2007

Jakarta Commons Logging and SLF4J

As a regular user of Jakarta Commons Logging (JCL) library I was surprised by the fact that there is a class loader problem in version 1.0.4. You can find more information here along with examples. There is also a specific JCL Wiki page about this problem. However, according to actual release notes of version 1.1 this issue seems to be fixed and adapters for various implementations are provided in commons-logging-adapters-1.1.jar (at least this is my understanding). The reason why I haven't been suffering from this issue yet is probably due to the fact that we ship all jar files with each application and does not rely on any server shared libraries.

Related to this fact I found that some people recommend using Simple Logging Fasade for Java (SLF4J) library instead of JCL. They claim it is faster, more robust, simper and does not rely on specific class loader machinery. I haven't tried it myself yet but the part I like most is the parameterized logging message (with performance benefits).

Also I came across one another interesting page by Rod Waldholff (and author of JCL). Specifically the last part where he discusses scenarios where the JCL should be used and where it should NOT be used. I think I will consider his words the next time I use logging library in my new project.