1. Summary
  2. Files
  3. Support
  4. Report Spam
  5. Create account
  6. Log in

Main Page

From jaqlib

Jump to: navigation, search

Contents

Introduction

JaQLib (Java Query Library) is a compact Java library that supports programmers in querying all sorts of collections, databases and XML files in a compact and intuitive manner. It heavily makes use of Java Generics and follows the idea of fluent interfaces. JaQLib has one single entry point named org.jaqlib.Jaqlib. Starting from this class all functionality of JaQLib can be reached conveniently.

JaqLib only uses standard Java features like generics or dynamic proxies. It does not need any pre or post compile steps.

WHERE conditions can be specified by custom implementations of the WhereCondition interface, by using the where().element() expression and by using a method call recording mechanism:
First a recorder object must be created (= a JDK dynamic proxy). Then the programmer must call the desired method on the returned recorder object. This method call is recorded by JaQLib. When JaqLib evaluates the WHERE condition this method call is replayed on every selected element. The result of this method call is then evaluated against the condition that is specified after the WHERE clause.
This method call record mechanism uses JDK dynamic proxies for proxying interfaces and CGLIB for proxying classes. So if you want to record method calls on classes you have to download CGLIB and put it on the classpath of your application.

JaQLib uses the standard JDK Logging mechanism. Logging to the console can be activated by calling Jaqlib.enableConsoleLogging(). Custom log handlers can be registered by calling Jaqlib.DEFAULTS.registerLogHandler() These log messages also include descriptive string representations of all executed queries.

But examples are always better than some abstract descriptions. So lets continue with some basic examples:


Usage Scenarios

  • Selecting arbitrary elements from collections, maps, ... in everyday programming tasks.
  • Using the database query support for unit testing. E.g., when you want to read back previously inserted/updated/deleted data from database in order to check if the unittest worked correctly.
  • Using the database query support for simple applications that need a quick and easy way to select data from database (without the coding overhead of JDBC or OR-Mappers like Hibernate, EclipseLink, iBatis, MyBatis ...).
  • Using the database OR Mapping support for simple applications or prototypes.
  • Using the XML query support for mapping data of Webservices to Java objects.
  • Using the XML query support for performing code generation. Meta data can be specified in XML files and can be easily read into a Java object model. Using this object model code or other artefacts can be generated.


Roadmap


References


Links

Personal tools