I've been dealing with a problem in my application that has me forced to change the HibernateQuery in a way that casts the existing DateTime column I have within my database into a date for further processing.

I've looked around a little on here already and found a supposed solution using sqlGroupProjection which ended up looking like this for me.
    Projection dp = Projections.sqlGroupProjection("CAST("+sp.getIname()+" AS DATE",
                                                                       "CAST("+sp.getIname()+" AS DATE",
                                                                       new String[] {sp.getIname()},
                                                                       new Type[] {StandardBasicTypes.DATE});
This does work to some the extent that it now generates this in the SQL statement

CAST(ierstelltAm AS DATE)

Which would be correct if it wasn't for the fact that something is now missing. Usually when Hibernate generates these statements they're given unique identifiers, one of them being y[i]_ and the other somehow relating to the table/entity used in the syntax of entity[i]_.

Since these are all inbuilt hibernate functions I had expected the above method to generate something along these lines

CAST(auftrag8_.IErstelltAm AS DATE) as y1_

based on the fact that the code previously generated using the criteria system did look like this.

auftrag8_.IErstelltAm as y1_

The question is now how do I correctly cast something to another data type using hibernate criterie, if it's not the sqlGroupProjection method mentioned in other places -- or is this a syntactical/logical error on my part?