I am using JBoss EAP 6.1.0 with EJB/JPA. I have a User object with several Groups he belongs to and I'm trying to create this in the database using a three step method:

1. Save the user
2. Save the groups he belongs to
3. Query the database and return that new user

My problem is that step (3) always returns back null because the commit hasn't happened yet. Adding an `em.flush()` between step 2 and 3 does not help. I'm avoiding any @CASCADE annotations with the Groups so saving just the User and having Groups cascade is not an option. Here is sample code:

```
@Stateless
public class RegistrationService {

   @EJB
   UserDao userDao;

   public User registerNewUser(User user, List<Group> groups) {
       userDao.saveNewUser(user);
       userDao.saveNewGroupsToUser(user, groups);
       return userDao.findUser(user);
   }
}

```

And here is a simplified UserDao:

```
@Stateless
public class UserDao {

  @PersistenceContext
  private EntityManager em;

  public void saveNewUser(User user) {
    em.persist(user);
  }

  public void saveNewGroupsToUser(User user, List<Group> groups) {
    for (Group group : groups) {
       GroupToUser groupToUser = new GroupToUser(user, group);
       em.persist(groupToUser);
    }

  public User findUser(User user) {
    return em.createQuery("from User where user = :userId")
       .setParameter("userId",user.getUserId())
       .getSingleResult();
  }
}

```

What I have found is that if I annotate the `findUser(User)` method with a `@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)` it works as expected. Why is this though? I thought `registerNewUser()` created one big transaction, and then findUser() would create a nested transaction which shouldn't know about the saving yet?