From: http://www.avaje.org/topic-120.html
@ManyToMany
/*@JoinTable(
name="event_group" ,
joinColumns =
@JoinColumn(name="event_id"),
inverseJoinColumns =
@JoinColumn(name="usergroup_id")
) */
private List groups;
.
.
.
Query q = Ebean.createQuery(Event.class);
q.join("groups");
q.where("groups.id=1");
final List eventList = q.findList();
.
.
select e.id, e.startdate, e.enddate, e.cdate, e.minpeople, e.maxpeople, e.comment, e.canceled, e.reason, e.deleted, e.archived, e.creator_id, e.category_id, e.location_id, g.id, g.name, g.description
from event e
left outer join event_group d on e.ID = d.event_id
left outer join usergroup g on e.usergroup_id = g.ID
where g.id=1
-------------------------------
the join is wrong.
left outer join usergroup g on e.usergroup_id = g.ID
should be
left outer join usergroup g on d.usergroup_id = g.ID