Hi guys,I would like to create JPA query based on this tables

**category**                                              
 
(pk)CategoryID int (10)
category VARCHAR (45)         
 
**templatecat**
 
(pk/fk)templateId int(10)       
(pk/fk)categoryId int (10) 
 
 **template**
 
(pk)templateId int (10)
template madiumtext


I also have a "tempaltecat" table that holds foreign keys for category and template table.I`d like to create query that finds all templates in template table based on category and vice versa.

Here is my table mapping

@Entity
@Table(name = "category")
@OneToMany(cascade = CascadeType.ALL)
@JoinTable(name = "templatecat", joinColumns = { @JoinColumn(name = "categoryId", unique = true) }, inverseJoinColumns = { @JoinColumn(name = "templateId") })
 
private Set<Template> template;
 
@Entity
@Table(name = "template")
@ManyToOne(optional = true)
@JoinTable(name = "templatecat", joinColumns = { @JoinColumn(name = "templateId") }, inverseJoinColumns = { @JoinColumn(name = "categoryId") })
 
private Category category;

Thanks in advance