Retrieve individual months from a database using HQL

I have a field java.util.Datein @Entityand would like to get individual months from this column.

Suppose I only had three lines: from 14/07/2010, 24/11/1975 and 03/11/1975 (European date format is day / month / year), I would like to get the following back from Hibernate to go in the drop-down list for filtering data:

07/2010
11/1975

(or the corresponding Date objects with other fields set to zero - honestly, exactly how the data is returned is not too important, as I can get around this).

I assume that an agnostic database approach in HQL is not possible - any suggestions?

+5
source share
1

:

select distinct month(c.birthday), year(d.birthday) from Cat c
+12

All Articles