2017-04-19 124 views
1

我在存儲庫類中使用Spring Data JPA的@Query註釋。當我在PL-SQL開發者中運行相同的SQL時,它返回結果,但不在應用程序內部。問題是什麼 ?我如何解決它?請幫助。 在此先感謝@Query不返回任何結果

我的回購類:

@Repository 
public interface FiberChannelRepository extends FndJpaRepositiry<FiberChannel, Long> { 

    @Query("select n.id, c.id, loc from FiberChannel fc left join Channel c on fc.id=c.id left join ChannelNode cn on c.id = cn.id and cn.deleted != true left join Node n on cn.id = n.id and cn.deleted != true left join Location loc on loc.id = n.id and cn.deleted != true where fc.id=?1") 
    List<Object[]> findNodesByFiber_Id(Long idFiber); 

} 

SQL變種:

select n.id_node, c.id_channel, loc.* 
    from Fiber_Channel fc 
     left join channel c on fc.id_channel=c.id_channel 
    left join CHANNEL_NODE cn 
     on c.id_channel = cn.id_channel and cn.is_deleted != 1 
    left join Node n 
     on cn.id_node = n.id_node and cn.is_deleted != 1 
    left join Location loc 
     on loc.id_location = n.id_location and cn.is_deleted != 1 where 
fc.id_fiber=42266 

回答

0

我解決我的問題。我在查詢sql中犯了錯誤。我用fc.fiber.id替換fc.id,它現在可以工作。