This blog for Hibernate Generic DAO Project has been moved to WordPress http://hibernategenericdao.wordpress.com/. Bye bye Blogger!

Thursday, March 19, 2009

Release 0.4.2

We just release a new build 0.4.2. It adds some handy new features to the search and tightens down null handling on the search.

The main new feature of 0.4.2 is the collection operators for search filters. These include SOME, ALL, NONE, EMPTY and NOT_EMPTY operators. These are fairly self-explanatory:

  SOME matches collections where the specified condition is true for at least one element.
  ALL matches collections where the specified condition is true for every element.
  NONE matches collections where the specified condition is not true for any elements.

  EMPTY matches collections that have no elements.
  NOT_EMPTY matches collections that have at least one element.

Additionally, EMPTY matches null values of non-collection types and empty strings in string types. Of course NOT_EMPTY does the inverse.

NULL and NOT_NULL operators were added to replace using the EQUAL operator with a null value. EQUAL operators with null values are now ignored.

Now if any filter with an operator that expects a value has a null value, that filter is ignored.

Finally, we ensured proper support for HQL special properties ".id", ".class" and ".size". Anywhere these can be used in HQL they can also be used in a search.

For further explanation and examples of all this functionality, see the section on filtering in http://code.google.com/p/hibernate-generic-dao/wiki/Search.


Another addition are the search walkers in SearchUtil. These are utilities for walking the lists of filters, fields, sorts and fetches in a search. Without these tools it can be especially tricky to visit every filter in a list because filters can have sub-filters, but these walkers provide the additional advantage of preserving the original list and only duplicating it if changes are made.

One purpose of these walkers might be to check for references to certain properties and alter or remove them. We use them internally to clean up null values and do validity and security checks on searches before we process them.

See the javadoc:

And an example:

No comments:

Post a Comment