Java 返回列表<;对象>;使用Hql查询从投影接口

Java 返回列表<;对象>;使用Hql查询从投影接口,java,spring,spring-boot,jpa,hql,Java,Spring,Spring Boot,Jpa,Hql,我有一个lineItem实体 @Entity @JsonInclude(value = Include.NON_NULL) public class LineItem extends AbstractEntity<LineItem> { private int rank; @JsonIgnore @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(nullable = false) private Or

我有一个lineItem实体

@Entity
@JsonInclude(value = Include.NON_NULL)
public class LineItem extends AbstractEntity<LineItem>
{
    private int rank;
    @JsonIgnore
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(nullable = false)
    private OrderEntity orderEntity;
    @ManyToOne(optional = false, fetch = FetchType.EAGER)
    private Service service;

    private long quantity;
    private BigDecimal unitPrice;

    @ElementCollection
    private List<HyperFile> files = new ArrayList<HyperFile>();

和行项目的投影dto

ublic interface RFQDto
{
    Service getService();

    List<HyperFile> getFiles();

    LineItemStatus getStatus();

    UUID getId();

    LocalDateTime getUpdated();

    long getQuantity();

    OrderEntity getOrderEntity();

    interface OrderEntity
    {
        OrderStatus getStatus();
    }

    interface List<HyperFile>
    {
        UUID getId();

    }
当从查询中删除“l.files As files”时,它会运行,但在files字段中返回null

public interface LineItemRepository
        extends PagingAndSortingRepository<LineItem, UUID>, JpaSpecificationExecutor<LineItem>
{
    Optional<LineItem> findOneByIdAndOrderEntity_Organization_Id(UUID id, UUID orgId);

    @Query("SELECT l.id AS id, l.service AS service," + "l.status AS status,l.updated AS updated," + "l.files As files"
            + "l.quantity AS quantity," + "l.orderEntity As orderEntity FROM LineItem l "
            + "WHERE l not in (select q.lineItem from Quotation q where q.partner=?2)   "
            + "and l.service in (?1) and l.status=?3 and l.orderEntity.status=?4")
    Page<RFQDto> findByServiceIn(List<Service> services, Organization org, LineItemStatus status,
            OrderStatus orderStatus, Pageable page);
...

如何使用query返回文件作为对象列表

出现错误的根本原因是什么?我怀疑Spring数据不喜欢混合基于接口和基于类的投影。尝试为
Hyperfile
getter声明一个接口,并将其用作
RFQDto.files
列表的元素类型,而不是在投影接口内声明它。如果这样做不起作用,Hyperfile在元素集合中出现错误的根本原因是什么?我怀疑Spring数据不喜欢混合基于接口和基于类的投影。尝试为
Hyperfile
getter声明一个接口,并将其用作
RFQDto.files
列表的元素类型,而不是在投影接口内声明它,如果这样做不起作用,则Hyperfile在元素集合中
public interface LineItemRepository
        extends PagingAndSortingRepository<LineItem, UUID>, JpaSpecificationExecutor<LineItem>
{
    Optional<LineItem> findOneByIdAndOrderEntity_Organization_Id(UUID id, UUID orgId);

    @Query("SELECT l.id AS id, l.service AS service," + "l.status AS status,l.updated AS updated," + "l.files As files"
            + "l.quantity AS quantity," + "l.orderEntity As orderEntity FROM LineItem l "
            + "WHERE l not in (select q.lineItem from Quotation q where q.partner=?2)   "
            + "and l.service in (?1) and l.status=?3 and l.orderEntity.status=?4")
    Page<RFQDto> findByServiceIn(List<Service> services, Organization org, LineItemStatus status,
            OrderStatus orderStatus, Pageable page);
...
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: