Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/hibernate/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Hibernate 如何在HQL中查询不同的日期_Hibernate_Date_Hql_Distinct - Fatal编程技术网

Hibernate 如何在HQL中查询不同的日期

Hibernate 如何在HQL中查询不同的日期,hibernate,date,hql,distinct,Hibernate,Date,Hql,Distinct,我有一个表,在postgres中有一个timestamp类型的列创建时间。在我的一个类中,我需要使用HQL检索所有不同的创建时间。我尝试过不同的查询,如: select distinct cast(creation_time as date) from Product; 但它总是返回产品对象的列表!。然后我试过这个: select year(pr.creationTime),month(pr.creationTime), day(pr.creationTime) from Product as

我有一个表,在postgres中有一个timestamp类型的列创建时间。在我的一个类中,我需要使用HQL检索所有不同的创建时间。我尝试过不同的查询,如:

select distinct cast(creation_time as date) from Product;
但它总是返回产品对象的列表!。然后我试过这个:

select year(pr.creationTime),month(pr.creationTime), day(pr.creationTime) from Product as pr;
但是这个也不起作用,它给出了一个错误:

function year(timestamp without time zone) does not exist
这方面有什么帮助吗?

可以使用

select distinct to_char(creation_time, 'mm/dd/yyyy') from Product;