Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/13.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
Java 使用EntityGraph时,DTO会导致QueryException_Java_Spring_Spring Boot_Spring Data - Fatal编程技术网

Java 使用EntityGraph时,DTO会导致QueryException

Java 使用EntityGraph时,DTO会导致QueryException,java,spring,spring-boot,spring-data,Java,Spring,Spring Boot,Spring Data,我的项目中有以下两个DTO public interface DeviceDTOMini { String getName(); ClientDTOMini getClient(); } public interface DeviceDTOFull { String getName(); ClientDTOMini getClient(); DeviceModelDTOMini getDeviceModel(); } 以下是获取数据的存储库方法: @En

我的项目中有以下两个DTO

public interface DeviceDTOMini {
    String getName();
    ClientDTOMini getClient();
}
public interface DeviceDTOFull {
    String getName();
    ClientDTOMini getClient();
    DeviceModelDTOMini getDeviceModel();
}
以下是获取数据的存储库方法:

@EntityGraph( attributePaths =  {"client","deviceModel"} )
<T> Page<T> findAllByClientIdAndDeletedAtIsNull( Long clientId, Pageable pageable, Class<T> type );
@EntityGraph(attributePath={“客户端”,“设备模型”})
Page FindAllByClientId和DeleteDatisNull(长clientId,可分页,可分页,类类型);
上述方法适用于DeviceToFull,但在使用DeviceToMini时会出现以下错误:

org.hibernate.QueryException:查询指定的联接获取,但 所提取关联的所有者不在选择列表中 [FromElement{显式,不是集合联接,获取联接,获取非惰性 属性,classAlias=generatedAlias1,role=com.test.test.model.device.device.client,tableName=clients,tableAlias=client1,origin=devices device0\u,列={device0\u.client\u id ,className=com.test.test.model.client.client}][select generatedAlias0.name,generatedAlias0.id,generatedAlias0.uuid from com.test.test.model.device.device作为生成的ALIAS0左连接 generatedAlias0.client作为generatedAlias1,其中( generatedAlias1.id=:param0)和(generatedAlias0.deletedAt为null )]; 嵌套异常为java.lang.IllegalArgumentException: org.hibernate.QueryException:查询指定的联接获取,但 所提取关联的所有者不在选择列表中 [FromElement{显式,不是集合联接,获取联接,获取非惰性 属性,classAlias=generatedAlias1,role=com.test.test.model.device.device.client,tableName=clients,tableAlias=client1,origin=devices device0\u,列={device0\u.client\u id ,className=com.test.test.model.client.client}][select generatedAlias0.name,generatedAlias0.id,generatedAlias0.uuid from com.test.test.model.device.device作为生成的ALIAS0左连接 generatedAlias0.client作为generatedAlias1,其中( generatedAlias1.id=:param0)和(generatedAlias0.deletedAt为null )]

我搜索了很多,找到了一些链接,但没有一个能提供解决方案。然而,所有这些都只提到了变通方法

是否有任何解决方案只从JPA获取必需字段