Many to Many broken after upgrade from Cuba 6 to Cuba 7

A previously working jpql query no longer works after upgrade from Cuba 6 to Cuba 7.0.

Both entities have the corresponding attributes mapped with @ManyToMany and @JoinTable(with explicit name, joinColumns and inverseJoinColumns). All the scaffolding was made by Cuba Studio.

The query joins a many to many relation.

select si from antilope_StuffInstance si join fetch si.tasks tk where tk.taskEnd >= :fromDate and tk.taskBegin <= :toDate and tk.id <> :task

Error:
Cannot resolve joined entity [Join variable: tk]

The relation is “implicit”, there is no declared entity joining the two.

I also managed to upgrade the project to 7.1 but the error is still there.