Skip to main content

Posts

Showing posts from 2014

Use PostgreSQL Full Text Search With HQL

Full Text Search (FTS) is a great mechanism that can be used to search the database against a search term. FTS can produce miraculous results when used efficiently. The PostgreSQL database has inbuilt library for FTS and provides various functions to make use of it. It also has a special data type called "tsvector" to store the keywords(tokens) that take part in the searching process. We are not going to discuss about how Postgres handles FTS, but we will discuss about how to use this with Hibernate HQL(Hibernate Query Language). For more info about full text searching with postgres, you can visit This link. To use FTS with Hibernate, we will have to first create a POJO (say PostgreSQLFullTextSearchFunction ) which implements SQLFunction interface. We are going to use the custom Dialect java class (say CustomPostgresDialect ) in the SessionFactory configuration. In this custom dialect class, you will have to register a new SQL function by passing the object of PostgreSQLF...

External Pagination & Sorting With Display Tag

We often come across the need to display data of any web application in a tabular form to the end user.There are several ways to do this using different kind of technologies e.g. Jquery's JQGrid etc. One such technology in JSP is to use the "displaytag" library. The display tag allows the programmer to provide the end user very basic but important features of: 1. Sorting the contents of the displayed list based on the sort order(Ascending/Descending) and sort property (First Name/Last Name etc.). 2. Navigating to other records if the list is quite large (Pagination). 3. Exporting the displayed data in any of the file formats like PDF, Excel etc. 4. Customizing the design (look & feel) of the displayed table via a properties file or inline properties. By default display table is configured to use the internal Pagination and Sorting. I am going to describe that how we can use the External pagination and/or sorting with display table in this post. Assuming that w...