使用 HQL 从数据库获取不同月份
我在 @Entity
中有一个 java.util.Date
字段,并且希望从该列中获取不同的月份。
假设我只有三行,分别是 14/07/2010、24/11/1975 和 03/11/1975(欧洲日期格式 - 日/月/年),我想从 Hibernate 获取以下内容以进入用于过滤数据的下拉列表:(
07/2010
11/1975
或其他字段设置为零的相应日期对象 - 说实话,数据返回的方式并不是太重要,因为我可以解决这个问题)。
我猜 HQL 中的数据库不可知方法是不可能的 - 有什么建议吗?
I have a java.util.Date
field in an @Entity
and would like to get the distinct months from that column.
Suppose I only had three rows, with 14/07/2010, 24/11/1975 and 03/11/1975 (European date format - day/month/year), I would like to get the following back from Hibernate to go into a dropdown for filtering the data:
07/2010
11/1975
(or corresponding Date objects with the other fields set to zero - to be honest precisely how the data comes back isn't too important as I can work around that).
I'm guessing a database-agnostic approach in HQL isn't possible - any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
怎么样:
What about :