Good afternoon, there are 2 Entity:

@Entity @Table(name = "Categories") public class Category { @Id @Expose private String title; @Expose(serialize = false) @OneToMany(mappedBy = "category",fetch = FetchType.LAZY) private List<Ord> orders = new ArrayList<>(); @Expose(serialize = false) @ManyToMany(mappedBy = "categories") private List<Provider> providers = new ArrayList<>(); 

and

 @Entity @Table(name = "Providers") public class Provider { @Id @Expose private String title; @Expose private String phone; @Expose private String mobilePhone; @ManyToMany @Expose(serialize = false) @JoinTable(name = "provider_category", joinColumns = {@JoinColumn(name = "provider",referencedColumnName = "title")}, inverseJoinColumns = {@JoinColumn(name = "category",referencedColumnName = "title")}) private List<Category>categories = new ArrayList<>(); 

I am trying to make a supplier request with a category:

 "FROM Provider as p LEFT JOIN p.categories as c WHERE c.title=:title" 

does not work ... What's wrong? Thank.

  • I tried this way: {"FROM provider_category pc WHERE pc.category = 'title'"} doesn't work either - Nikolay Egorov
  • And what does "not work" mean? Error, wrong result, what exactly? - Roman

1 answer 1

Understood. It was necessary:

  "SELECT p FROM Provider p join p.categories c WHERE c.title=:title"