代码之家  ›  专栏  ›  技术社区  ›  robert trudel

带子查询的Delete提供了无效的路径

  •  0
  • robert trudel  · 技术社区  · 7 年前

    我试着删除。

    我的班级

    public Scpi{
        @Id
        ....
        private Integer id;
    
        @ManyToMany(mappedBy = "scpi")
        private Set<Asi> asi = new HashSet<>();
    
        ...
    }
    
    public Asi{
        @Id
        ....
        private Integer id;
    
        @ManyToOne
        private Spi spi;
    
        ...
    }
    

    我的删除

    @Modifying
    @Query("delete from Scpi scpi where scpi.id in ( select spci2.id from Scpi scpi2 inner Join spci2.asi asi inner Join asi.spi spi where spi.id= ?1)")
    

    我得到的错误

    org.hibernate.hql.internal.ast.InvalidPathException:无效路径: '间谍2.asi'

    你知道吗?

    1 回复  |  直到 7 年前
        1
  •  1
  •   kj007 XdebugX    7 年前

    你的sql好像有错,应该是 scpi2.asi 而不是 spci2.asi scpi2.id

    @Modifying
    @Query("delete from Scpi scpi where scpi.id in ( select scpi2.id from Scpi scpi2 inner Join scpi2.asi asi inner Join asi.spi spi where spi.id= ?1)")