I have 2 Entities "User" and "Group". Actually this is a ManyToMany association but I want to persist additional informations in the relation table like created or userid.

So I found out that I have to introduce a new entity which represents the relation table "UserGroup".

The tables:

**user** id, name, pw

**group** id, name

**usergroup** id, userid, groupid, created, createduserid

The entities:

```
@Entity
@Table(name="user")
public class User {
  @OneToMany(mappedBy="user")
  List<UserGroup> groups;
}

@Entity
@Table(name="group")
public class Group {
  @OneToMany(mappedBy="group")
  List<UserGroup> users;
}

@Entity
@Table(name="usergroup")
public class UserGroup {
  @ManyToOne
  User user;

  @ManyToOne
  User group;

  @Column(name="created")
  Date created;

  // ...
}

```

Now due to Domain Driven Design I would have to introduce 
in my User Entity methods like: User::addGroup(group), User::removeFromGroup(group).
But technically this appears to be impossible because I need to create 
a UserGroup entity, inject the User and Group object and finally persist
it with the EntityManager.

Is there a more elegant solution or do I really have to do this operations outside of my entities in service objects?

(With ManyToMany I can do this in the entities.)