vohoaiviet / hibernate-generic-dao

Automatically exported from code.google.com/p/hibernate-generic-dao
0 stars 0 forks source link

Enhancement - Custom sort #72

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
First - excellent code - and many thnx
I have Employee table with employeeref (string) where I wanted to change for a 
specific customer so that it sorted numerically

In the end I created a CustomHibernateSearchProcessor so that I could add a 
Sort of type

soEmployee.addSort(new Sort("(cast(employeeno as integer))"));

As I couldnt extend the HibernateSearchProcessor (problems with private super 
constructor) I basically redid it while overriding the BaseSearchProcesor 
generateOrderByClause to 'recognise' the special backet wrapped string and us 
that directly
eg
if (sort.getProperty().startsWith("(")) ..

I also had to override the securityCheckProperty and use a modified INjection 
check

While it is not that elegant, I thought I would pass on my experiences in case 
you might consider it as an enhancement.

Original issue reported on code.google.com by danielgo...@yahoo.com on 11 Nov 2010 at 11:25

GoogleCodeExporter commented 8 years ago
I just created Issue 73 to include this an other related needs.

Original comment by dwolvert on 13 Nov 2010 at 3:19