Consider the following two relations:
@Entity class Foo {
@Id id;
@ManyToMany
@JoinTable(name = "ATag",
joinColumns = @JoinColumn(name = "foo_id"),
inverseJoinColumns = @JoinColumn(name = "tag_id"))
Set<Tag> tags;
}
@Entity class Tag {
@Id Long id;
String name;
}
There is no corresponding entity class for the join table ATag. Now, I want to get all Foo instances with Tag named 'tag1'. Is it possible using only Criteria?
A subquery may be helpful. However, I can't create DetachedCriteria for class ATag.class which doesn't existed.