Hibernate查询日期仅在年份和月份进行比较 [英] Hibernate query date compare on year and month only

查看:116
本文介绍了Hibernate查询日期仅在年份和月份进行比较的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从一个列 birthDate 这是一个 Date (没有时间)。我需要通过仅比较年份和月份来筛选记录。
例如我想要1990年3月出生的所有用户。这一天并不重要。

I need to grab some records from a table which has a Column birthDate which is a Date(without time). I need to filter records by comparing against year and month only. For example I want all the users born on March of 1990. The day doesn't matter.

你如何处理它?<​​/ p>

How do you handle it?

推荐答案

您可以使用实体中的,其中to_char(birthDate,'YYYY / MM')='1990/03' code>
这将适用于HQL

You can use from Entity where to_char(birthDate,'YYYY/MM') = '1990/03' this will work for HQL

这篇关于Hibernate查询日期仅在年份和月份进行比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆