currently I use this code-snipplet throughout my code:
@ManyToMany(cascade = CascadeType.ALL)
@JoinTable(
name="event_group" ,
joinColumns =
@JoinColumn(name="event_id"),
inverseJoinColumns =
@JoinColumn(name="usergroup_id")
)
private Set<Usergroup> groups;
if ( groups == null ) {
final BeanSet<Usergroup> set = new BeanSet<Usergroup>();
set.setModifyListening(BeanCollection.ModifyListenMode.ALL);
setGroups(set);
}
return groups;
to avoid nullpointer-exceptions. it would be nice if ebean could automate this process.