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
Hibernate DISTINCT在JPA中使用的是哪一列?是否可以更改它?_Hibernate_Jpa_Jpql - Fatal编程技术网

Hibernate DISTINCT在JPA中使用的是哪一列?是否可以更改它?

Hibernate DISTINCT在JPA中使用的是哪一列?是否可以更改它?,hibernate,jpa,jpql,Hibernate,Jpa,Jpql,JPQL中的Distinct最常用于在执行左外部联接时选择一个Distinct对象 此查询: select distinct sirm.attribute from store_item_received_material sirm where sirm.store_item_id in (select si.id from store_item si where si.program_id = 9 and si.customer_id = 1 and si.date_processed is

JPQL中的Distinct最常用于在执行左外部联接时选择一个Distinct对象

此查询:

select distinct sirm.attribute
from store_item_received_material sirm
where sirm.store_item_id in (select si.id from store_item si where si.program_id = 9 and si.customer_id = 1 and si.date_processed is not null);
将在地址集合中选择客户及其所有地址。如果您不在此处使用DISTINCT,则同一客户将为每个地址重复一次

您也可以使用DISTINCT选择列,但它将只返回该列:

SELECT DISTINCT c
FROM Customer c
LEFT JOIN FETCH c.addresses

这样,结果列表将是一个包含客户名称的字符串集合。

JPQL中的Distinct最常用于在执行左外部联接时选择一个Distinct对象

此查询:

select distinct sirm.attribute
from store_item_received_material sirm
where sirm.store_item_id in (select si.id from store_item si where si.program_id = 9 and si.customer_id = 1 and si.date_processed is not null);
将在地址集合中选择客户及其所有地址。如果您不在此处使用DISTINCT,则同一客户将为每个地址重复一次

您也可以使用DISTINCT选择列,但它将只返回该列:

SELECT DISTINCT c
FROM Customer c
LEFT JOIN FETCH c.addresses

这样,结果列表将是一个包含客户名称的字符串集合。

引用这一个,它可能会有帮助引用这一个,它可能会有帮助