Java 不带联接关系的Spring数据jpa find()
我写了下面的查询,在“设备”和“帐户”之间有一个m:n关系,但是对于本机查询,它仍然返回带有内部联接的结果Java 不带联接关系的Spring数据jpa find(),java,mysql,spring,spring-data-jpa,Java,Mysql,Spring,Spring Data Jpa,我写了下面的查询,在“设备”和“帐户”之间有一个m:n关系,但是对于本机查询,它仍然返回带有内部联接的结果 public interface DeviceRepository extends JpaRepository<Device, Long> { @Query(value = "select device.* from device #pageable", countQuery = "select count(*) from dev
public interface DeviceRepository extends JpaRepository<Device, Long> {
@Query(value = "select device.* from device #pageable",
countQuery = "select count(*) from device",
nativeQuery = true)
Page<Device> findByNative(Pageable peagble);
}
实际上,我需要这个,因为我不想让findAll中的帐户[]仅在findById中用@SqlResultSetMapping解决这是什么意思?它仍然使用内部联接返回结果?返回两个表中的所有字段,更新的问题…这是hibernate如何翻译您的问题,那么问题在哪里?问题是本机查询,而不是本机查询!那么我怎样才能阻止加入呢?
SELECT
accounts0_.device_id AS device_i1_2_0_,
accounts0_.account_id AS account_2_2_0_,
account1_.id AS id1_0_1_,
account1_.broker_id AS broker_i2_0_1_,
account1_.is_deleted AS is_delet3_0_1_,
account1_.user_id AS user_id4_0_1_
FROM
device_account accounts0_
INNER JOIN
account account1_ ON accounts0_.account_id = account1_.id
WHERE
accounts0_.device_id = ?