java – Hibernate Criteria – Group Dates

Question:

Currently I can group dates using Projections.sqlGroupProjection(). When my date field is in the same class as I create Criteria, it works just fine. The problem is when I create an alias, and the data field I want to group is inside this alias class. Inside my sqlGroupProjection it doesn't recognize the aliases that hibernate gives the classes.

Does anyone have any idea how to get around this situation or another way to group dates without using the "Extract" function?

Answer:

I found the solution here: http://www.dclick.com.br/2007/11/14/implementando-criterion-para-utilizar-extract-do-oracle/

In the example it says Oracle, but it worked on postgreSQL too.

Scroll to Top
AllEscort