java – Hibernate Criteria – Group Dates


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?


I found the solution here:

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

Scroll to Top