Search This Blog

Wednesday, 31 October 2012

Formatting code using Eclipse

We all write code. But how many of us write clean well formatted code ? Do we care if our classes are correctly indented ? Does it affect us when our IDE shows tiny yellow warnings? Warnings that scream "unused variable" or "unchecked code" ?

Tuesday, 30 October 2012

The wrong result when using fetch and DISTINCT keywords

Consider a query to fetch all entities who have a child with id 1.
public static void testQuerySingleE() {
    final Session session = sessionFactory.openSession();  
    Transaction transaction = session.beginTransaction();

Saturday, 27 October 2012

HQL and the new keyword

It often happens that for a particular use case we need columns from several different tables. Consider the case where we would like the Entity name and its Master Name to be displayed.

Thursday, 25 October 2012

Theta Style Joins

Consider the below queries to find all children of an entity:
public static void testGetEntityChild() {
    final Session session = sessionFactory.openSession();

Wednesday, 24 October 2012

Querying and Outer Joins

In the previous post we saw HQL 's support for inner joins. With inner joins, a rows is returned when there is at least one row from both tables that matches the join condition. However it may be needed that rows are returned even when there are no matches through the join criteria.