Hi all,
I have the following relevant ejb3 entity beans (i've excluded a lot of code for simplicity so it will probably look incomplete):
User:
@Column(name = "username",
nullable = false,
unique = true)
String username;
@OneToMany(cascade = CascadeType.ALL,
mappedBy = "groupowner",
fetch = FetchType.EAGER)
Set<Group> groups;
@ManyToMany(cascade = {CascadeType.REFRESH, CascadeType.MERGE},
mappedBy = "members",
fetch = FetchType.EAGER)
@JoinTable(name = "user_group_link",
joinColumns = @JoinColumn(name = "user_id"),
inverseJoinColumns = @JoinColumn(name = "group_id"))
Set<Group> memberships;
Group:
@ManyToMany(cascade = {CascadeType.REFRESH,
CascadeType.MERGE},
fetch = FetchType.EAGER)
@JoinTable(name = "user_group_link",
joinColumns = @JoinColumn(name = "group_id"),
inverseJoinColumns = @JoinColumn(name = "user_id"))
private Set<User> members;
--- --- ---
I am trying to execute the following:
String mystmt = "SELECT name FROM Group g WHERE :user IN (g.members)";
Query query = manager.createQuery(mystmt);
query.setParameter("user", myuser);
Hibernate spits this out in my log:
select group0_.name as col_0_0_ from group group0_, user_group_link members1_, user user2_ where group0_.group_id=members1_.group_id and members1_.user_id=user2_.user_id and (? in (.))
Then I get the following errors:
WARN [org.hibernate.util.JDBCExceptionReporter] SQL Error: 0, SQLState: 42601
ERROR [org.hibernate.util.JDBCExceptionReporter] ERROR: syntax error at or near "."
org.postgresql.util.PSQLException: ERROR: syntax error at or near "."
I cannot see why there would be a problem with my HQL.
Can anyone help?
Thanks,
pea
|