Skip to main content


Showing posts from 2016

How could I be so stupid using hibernate criteria with timestamp?

I needed to make a query to find all records valid today for columns with effectiveFrom and effectiveTo range
I spent a couple of hours trying to understand why


was giving no results.

After many trials and attempts with other criteria tricks, I remembered that hibernate is not comparting if  currentDate.getTime is greater than effectiveFrom, but if effectiveFrom is greater than currentDate.getTime
So correct sintax for it was the exact opposite


This one worked as it should

Java ALWAYS passes by value (and it is ALWAYS an interesting discussion)

Always good as a refresher.

So, when calling a method For primitive arguments (int, long, etc.), the pass by value is the actual value of the primitive (for example, 3).For objects, the pass by value is the value of the reference to the object.

How I ran Gradle with cntlm

I was behind a corporate firewall and had to run gradlew (gradle) from Cygwin. The system was running a cntlm authentication proxy.

I ran the following command

export http_proxy=
export https_proxy=$http_proxy

Then I ran

./gradlew -Dhttps.proxyHost= -Dhttps.proxyPort=3128 -Dhttp.proxyHost= -Dhttp.proxyPort=3128

I hope it helps

Did you know?

Did you know hat  pressing CTRL + directional arrows allows you to browse a text document by skimming entire words?

This discovery is going to change my life!

UNION makes ALL the strength

Following the advice from a very expert consultant, I changed my views from an UNION between two select from the same table to UNION ALL and the performance improvements were simply amazing. Before doing so, I had verified that the query were returning different results with the INTERSECT command before doing so.

The difference is that UNION verifies that records are unique, while UNION ALL doesn't. The performance gain is very remarkable

Hibernate Stored Procedure with first parameter not "OUT"

I spent some days trying to call a Stored Procedure through Hibernate. I used CreateSQLQuery  and I made my own custom transformer, but I could not get it work. I keep geeting Wrong Type and Parameter of procedure exception.

My procedure was like the following

    procedure GET_BY_EMPLOYEE (
      , P_DATE_FROM  in       date
      , P_DATE_TO    in       date
      , P_REF           out      CURSORREFERENCETYPE);

After days of searching, I found this

For Oracle the following rules apply:

A function must return a result set. The first parameter of a procedure must be an OUT that returns a result set. This is done by using a SYS_REFCURSOR type in Oracle 9 or 10. In Oracle you need to define aREF CURSOR type. See Oracle literature for further information.
So there is no way to get this procedure to work in hibernate. I will use a plain JDBCTemplate.