Spring Jpa findAllBy*使用长id而不是实体

Spring Jpa findAllBy*使用长id而不是实体,spring,postgresql,spring-data-jpa,jpql,Spring,Postgresql,Spring Data Jpa,Jpql,我只是不想做: myEntity = findById(Long id) findAllByEntityAnd*(MyEntity myEntity, *) 相反,我想做: findAllByEntityAnd*(Long entityId, *) 是我错过了什么来实现我想要的,还是我无法直接实现 谢谢你的帮助~ 当我尝试时,弹簧提示我: java.lang.IllegalArgumentException: Could not create query metamodel for meth

我只是不想做:

myEntity = findById(Long id)
findAllByEntityAnd*(MyEntity myEntity, *)
相反,我想做:

findAllByEntityAnd*(Long entityId, *)
是我错过了什么来实现我想要的,还是我无法直接实现

谢谢你的帮助~

当我尝试时,弹簧提示我:

java.lang.IllegalArgumentException: Could not create query metamodel for method public abstract java.util.List com.worksap.morphling.raptor.dump.thread.dao.ThreadDoRepository.findAllByDumpDoAndLocksWaitingContains(java.lang.Long,java.lang.String)!
这是我的表格供你参考:

@Data
@Builder
@Entity
@Table(name = "thread_info")
@AllArgsConstructor
@NoArgsConstructor
public class ThreadDo implements Serializable {
    private static final long serialVersionUID = -1L;
    String name;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    @ManyToOne
    @JoinColumn(name = "thread_dump_id")
    @JsonIgnore
    private ThreadDumpDo dumpDo;

    ...
}

@Data
@Builder
@Entity
@Table(name = "thread_dump")
@AllArgsConstructor
@NoArgsConstructor
public class ThreadDumpDo implements Serializable {
    private static final long serialVersionUID = -1L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @OneToMany(
            mappedBy = "dumpDo",
            cascade = CascadeType.ALL,
            orphanRemoval = true
    )
    private List<ThreadDo> threadDoList;
}
我可以通过@Query实现它,如下所示,但我真的认为它很难看,因为我认为它很容易解释

@Query(value = "select * from thread_info t where t.thread_dump_id = ?1 and t.locks_waiting like ?2",
            nativeQuery = true)
List<ThreadDo> findAllByDumpDoAndLocksWaitingContains(Long dumpId, String lockWaiting);
试试这个

List<ThreadDo> findAllByDumpDo_IdAndLocksWaitingContains(Long dumpId, String lockWaiting);
List<ThreadDo> findAllByDumpDo_IdAndLocksWaitingContains(Long dumpId, String lockWaiting);