I have following Entity
@Entity
@Table(name = \"rule\")
public class Rule implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AU
The criteria query looks fine. Suppose we have tables:
rule(id, name,...)
action(id, name,..)
rule_action(id, rule_id, action_id,...) -- (or rule_id+action_id as a composite pkey)
The mapping should be as follows:
public class Rule {
...
@ManyToMany(mappedBy = "rule")
private Set actions;
...
}
public class Action {
...
@JoinTable(
name="rule_action",
joinColumns={@JoinColumn(name="action_id")},
inverseJoinColumns={@JoinColumn(name="rule_id")}
)
private Set rules;
...
}
This way your criteria query should work.