I have an entity as follows:
public class Foo {
private List<String> bars;
@ElementCollection(fetch=FetchType.LAZY)
@CollectionTable(name="T_BARS", joinColumns=@JoinColumn(name = "ID"))
@Column(name="BAR")
public List<String> getBars() {
return bars;
}
}
now I' m trying to query all the elements foo that contains bar elements with id 'a', 'b' or 'c' but I do not manage to make it work.
I tried the two following approaches:
select from FOO as f where f.bars in elements
(select b.id from T_BARS as b where b.bar in elements('a','b','c'))
this yields a QuerySyntaxException: T_BARS not mapped
My second approach was the following:
select from FOO as f where elements('a','b','c') in elements(f.bars)
this yields a QuerySyntaxException unexpected token
EDIT: I'm using envers, so joins do not seem possible!?